aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAmaresh Kumar <kamaresh@in.ibm.com>2018-09-03 20:41:47 +0530
committerAmaresh Kumar <kamaresh@in.ibm.com>2018-09-03 20:41:56 +0530
commitecc28463e0e98cab52e8b71df912cbfeac55c23e (patch)
treeba626416a3c1f026a287dbdc8021b724b0213849
parenta1cc0279360b09663c1b59fd0b89a1c2e081dfbd (diff)
Added sonar fixes in StatisticsServlet.java
https://sonar.onap.org/project/issues?id=org.onap.dmaap.datarouter%3Aparent&open=AWWKm3GexOv3LmQdDLM3&resolved=false&severities=BLOCKER&types=BUG Issue-ID: DMAAP-694 Change-Id: Ibd5ee6dd784627bc8afa6e26c82e2c2ceb62a9a9 Signed-off-by: Amaresh Kumar <kamaresh@in.ibm.com>
-rwxr-xr-xdatarouter-prov/src/main/java/org/onap/dmaap/datarouter/provisioning/StatisticsServlet.java37
1 files changed, 7 insertions, 30 deletions
diff --git a/datarouter-prov/src/main/java/org/onap/dmaap/datarouter/provisioning/StatisticsServlet.java b/datarouter-prov/src/main/java/org/onap/dmaap/datarouter/provisioning/StatisticsServlet.java
index e79d4705..33bf3a35 100755
--- a/datarouter-prov/src/main/java/org/onap/dmaap/datarouter/provisioning/StatisticsServlet.java
+++ b/datarouter-prov/src/main/java/org/onap/dmaap/datarouter/provisioning/StatisticsServlet.java
@@ -569,40 +569,17 @@ public class StatisticsServlet extends BaseServlet {
intlogger.debug(sql);
long start = System.currentTimeMillis();
DB db = new DB();
- Connection conn = null;
ResultSet rs = null;
- Statement stmt = null;
- PreparedStatement pst = null;
- try {
- conn = db.getConnection();
- stmt = conn.createStatement();
- pst = conn.prepareStatement(sql);
- rs = pst.executeQuery();
+ try (
+ Connection conn = db.getConnection()){
+ try(PreparedStatement pst = conn.prepareStatement(sql)){
+ rs = pst.executeQuery();
+ }
} catch (SQLException e) {
e.printStackTrace();
- } finally {
-
- try {
- if (conn != null) {
- db.release(conn);
- }
- if (stmt != null) {
- stmt.close();
- }
- if (pst != null) {
- pst.close();
- }
- if (rs != null) {
- rs.close();
- }
-
- } catch (SQLException sqlException) {
- intlogger.error("Exception in getting SQl Records",sqlException);
- }
-
+ }
intlogger.debug("Time: " + (System.currentTimeMillis() - start) + " ms");
-
return rs;
}
}
-}
+