From 5e31510dba7647b0d0873d9864a0ee6c309e2247 Mon Sep 17 00:00:00 2001 From: surya-huawei Date: Tue, 19 Sep 2017 14:57:17 +0530 Subject: Fix Sonar Issue One blocker issue in sli/core module *Check for null dereferencing Issue-Id: CCSDK-87 Change-Id: I5ebaef24b3fd6534b5e818c3087e3d8213ed770c Signed-off-by: surya-huawei --- .../java/org/onap/ccsdk/sli/core/dblib/CachedDataSource.java | 10 +--------- 1 file changed, 1 insertion(+), 9 deletions(-) (limited to 'dblib/provider') diff --git a/dblib/provider/src/main/java/org/onap/ccsdk/sli/core/dblib/CachedDataSource.java b/dblib/provider/src/main/java/org/onap/ccsdk/sli/core/dblib/CachedDataSource.java index a5902d54b..4d920e6a0 100755 --- a/dblib/provider/src/main/java/org/onap/ccsdk/sli/core/dblib/CachedDataSource.java +++ b/dblib/provider/src/main/java/org/onap/ccsdk/sli/core/dblib/CachedDataSource.java @@ -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; } -- cgit 1.2.3-korg