diff options
author | Arun S. Yerra <arun.yerra@huawei.com> | 2017-09-07 16:21:23 -0700 |
---|---|---|
committer | Arun S. Yerra <arun.yerra@huawei.com> | 2017-09-07 16:25:35 -0700 |
commit | f28ba9bec18a636a9d5ecb38851f8af973e91f63 (patch) | |
tree | b3d1c2e48960911e52b102bc3b6ad02351002fe7 /sli/common | |
parent | 606202a9854c74b98f31d10b72f0875bb0a42924 (diff) |
Fix sonar blocker issues in ccsdk/core module
Sonarqube report for CCSDK core identfied some blcoker issues. This fix addresses those bugs.
Issue-Id: CCSDK-84
Change-Id: Ie6ff19b7b0815a129f9809243e8e3eb0a64144ab
Signed-off-by: Arun S. Yerra <arun.yerra@huawei.com>
Diffstat (limited to 'sli/common')
-rw-r--r-- | sli/common/src/main/java/org/onap/ccsdk/sli/core/sli/SvcLogicDblibStore.java | 22 |
1 files changed, 18 insertions, 4 deletions
diff --git a/sli/common/src/main/java/org/onap/ccsdk/sli/core/sli/SvcLogicDblibStore.java b/sli/common/src/main/java/org/onap/ccsdk/sli/core/sli/SvcLogicDblibStore.java index f11b362c..9216519a 100644 --- a/sli/common/src/main/java/org/onap/ccsdk/sli/core/sli/SvcLogicDblibStore.java +++ b/sli/common/src/main/java/org/onap/ccsdk/sli/core/sli/SvcLogicDblibStore.java @@ -132,7 +132,7 @@ public class SvcLogicDblibStore implements SvcLogicStore { String mode) throws SvcLogicException { DbLibService dbSvc = getDbLibService(); - + PreparedStatement fetchGraphStmt = null; Connection dbConn = null; SvcLogicGraph retval = null; ResultSet results = null; @@ -146,7 +146,7 @@ public class SvcLogicDblibStore implements SvcLogicStore { try { dbConn = ((DBResourceManager) dbSvc).getConnection(); - PreparedStatement fetchGraphStmt; + ArrayList<String> args = new ArrayList<String>(); args.add(module); @@ -193,6 +193,13 @@ public class SvcLogicDblibStore implements SvcLogicStore { } catch (Exception e) { throw new ConfigurationException("Graph processing failed", e); } finally { + try { + if (fetchGraphStmt != null) { + fetchGraphStmt.close(); + } + } catch (SQLException e) { + LOG.info(e.getMessage()); + } if (results != null) { try { results.close(); @@ -267,12 +274,12 @@ public class SvcLogicDblibStore implements SvcLogicStore { } Connection dbConn = null; - + PreparedStatement storeGraphStmt = null; try { dbConn = ((DBResourceManager) dbSvc).getConnection(); boolean oldAutoCommit = dbConn.getAutoCommit(); dbConn.setAutoCommit(false); - PreparedStatement storeGraphStmt = dbConn + storeGraphStmt = dbConn .prepareStatement(storeGraphSql); storeGraphStmt.setString(1, graph.getModule()); storeGraphStmt.setString(2, graph.getRpc()); @@ -289,6 +296,13 @@ public class SvcLogicDblibStore implements SvcLogicStore { throw new SvcLogicException("Could not write object to database", e); } finally { try { + if (storeGraphStmt != null) { + storeGraphStmt.close(); + } + } catch (SQLException e) { + LOG.info(e.getMessage()); + } + try { if (dbConn != null && !dbConn.isClosed()) { dbConn.close(); } |