From 7272b810308f5a6ee402c4546154b6d61f565057 Mon Sep 17 00:00:00 2001 From: Amaresh Kumar Date: Tue, 28 Aug 2018 20:08:48 +0530 Subject: Fixed Critical Sonar Issues in LogServlet.java https://sonar.onap.org/project/issues?fileUuids=AWHFaQitEU5FCDfKtnEp&id=org.onap.dmaap.datarouter%3Aparent&resolved=false&severities=BLOCKER Issue-ID: DMAAP-668 Change-Id: I2d3990c446eabbfdf2a338ad109775a2f7aa0c1b Signed-off-by: Amaresh Kumar --- .../org/onap/dmaap/datarouter/provisioning/LogServlet.java | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) (limited to 'datarouter-prov/src') diff --git a/datarouter-prov/src/main/java/org/onap/dmaap/datarouter/provisioning/LogServlet.java b/datarouter-prov/src/main/java/org/onap/dmaap/datarouter/provisioning/LogServlet.java index 8614a6e8..101c9e6f 100644 --- a/datarouter-prov/src/main/java/org/onap/dmaap/datarouter/provisioning/LogServlet.java +++ b/datarouter-prov/src/main/java/org/onap/dmaap/datarouter/provisioning/LogServlet.java @@ -417,13 +417,13 @@ public class LogServlet extends BaseServlet { Connection conn = null; try { conn = db.getConnection(); - Statement stmt = conn.createStatement(); - ResultSet rs = stmt.executeQuery(sql); - while (rs.next()) { - rh.handleRow(rs); - } - rs.close(); - stmt.close(); + try( Statement stmt = conn.createStatement()){ + try(ResultSet rs = stmt.executeQuery(sql)){ + while (rs.next()) { + rh.handleRow(rs); + } + } + } } catch (SQLException sqlException) { intlogger.info("Failed to get Records. Exception = " +sqlException.getMessage(),sqlException); } finally { -- cgit 1.2.3-korg