Fix Sonar Issue
authorsurya-huawei <a.u.surya@huawei.com>
Tue, 19 Sep 2017 09:27:17 +0000 (14:57 +0530)
committerSURYA A U <a.u.surya@huawei.com>
Wed, 20 Sep 2017 06:24:56 +0000 (06:24 +0000)
One blocker issue in sli/core module
*Check for null dereferencing

Issue-Id: CCSDK-87
Change-Id: I5ebaef24b3fd6534b5e818c3087e3d8213ed770c
Signed-off-by: surya-huawei <a.u.surya@huawei.com>
dblib/provider/src/main/java/org/onap/ccsdk/sli/core/dblib/CachedDataSource.java

index a5902d5..4d920e6 100755 (executable)
@@ -603,22 +603,14 @@ public abstract class CachedDataSource implements DataSource, SQLExecutionMonito
 
        protected boolean unlockTable(Connection conn) {
                boolean retValue = false;
-               Statement lock = null;
-               try {
+               try (Statement lock = conn.createStatement()){
                        if(LOGGER.isDebugEnabled()) {
                                LOGGER.debug("Executing 'UNLOCK TABLES' on connection " + conn.toString());
                        }
-                       lock = conn.createStatement();
                        retValue = lock.execute("UNLOCK TABLES");
                } catch(Exception exc){
                        LOGGER.error("", exc);
                        retValue =  false;
-               } finally {
-                       try {
-                                lock.close();
-                       } catch(Exception exc) {
-
-                       }
                }
                return retValue;
        }