From: Amaresh Kumar Date: Fri, 31 Aug 2018 12:10:47 +0000 (+0530) Subject: Sonar fix for DB.java X-Git-Tag: 1.0.1~27^2 X-Git-Url: https://gerrit.onap.org/r/gitweb?p=dmaap%2Fdatarouter.git;a=commitdiff_plain;h=26fb914c67acb060987671e0ce12d584d9786e54 Sonar fix for DB.java https://sonar.onap.org/project/issues?id=org.onap.dmaap.datarouter%3Aparent&open=AWUebYr6wGn37JfbxiDE&resolved=false&severities=BLOCKER&types=BUG Issue-ID: DMAAP-680 Change-Id: I8760e8dd945e5b5e9792dfdaf3d0193f89c573a6 Signed-off-by: Amaresh Kumar --- diff --git a/datarouter-prov/src/main/java/org/onap/dmaap/datarouter/provisioning/utils/DB.java b/datarouter-prov/src/main/java/org/onap/dmaap/datarouter/provisioning/utils/DB.java index bbcacb53..7f0d56b7 100644 --- a/datarouter-prov/src/main/java/org/onap/dmaap/datarouter/provisioning/utils/DB.java +++ b/datarouter-prov/src/main/java/org/onap/dmaap/datarouter/provisioning/utils/DB.java @@ -112,13 +112,16 @@ public class DB { throw sqlEx; } } + finally { + if (connection != null && !connection.isValid(1)) { + connection.close(); + connection = null; + } + } } while (connection == null); } } - if (connection != null && !connection.isValid(1)) { - connection.close(); - connection = null; - } + } return connection; }