aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAmaresh Kumar <kamaresh@in.ibm.com>2018-09-04 18:52:48 +0530
committerAmaresh Kumar <kamaresh@in.ibm.com>2018-09-04 18:53:00 +0530
commit28d544f0c3b997da5628d4dcdb8e6773a0440cb4 (patch)
treea9863b05cdde7aba037b7efbfd65c91384b3c899
parente78029abb4dd73bf14e0291096d5b6762c55739b (diff)
Fixed Sonar issues in NodeClass.java
https://sonar.onap.org/project/issues?id=org.onap.dmaap.datarouter%3Aparent&open=AWWU4OsgxOv3LmQdDYyE&resolved=false&severities=BLOCKER&types=BUG Issue-ID: DMAAP-698 Change-Id: I1609a5c300e55f1eb8bd8b4966d456fb3905cc00 Signed-off-by: Amaresh Kumar <kamaresh@in.ibm.com>
-rwxr-xr-xdatarouter-prov/src/main/java/org/onap/dmaap/datarouter/provisioning/beans/NodeClass.java18
1 files changed, 7 insertions, 11 deletions
diff --git a/datarouter-prov/src/main/java/org/onap/dmaap/datarouter/provisioning/beans/NodeClass.java b/datarouter-prov/src/main/java/org/onap/dmaap/datarouter/provisioning/beans/NodeClass.java
index 1b368517..9d43bd0a 100755
--- a/datarouter-prov/src/main/java/org/onap/dmaap/datarouter/provisioning/beans/NodeClass.java
+++ b/datarouter-prov/src/main/java/org/onap/dmaap/datarouter/provisioning/beans/NodeClass.java
@@ -105,20 +105,20 @@ public abstract class NodeClass extends Syncable {
public static void reload() {
Map<String, Integer> m = new HashMap<String, Integer>();
PreparedStatement ps = null;
- ResultSet rs=null;
+
try {
DB db = new DB();
@SuppressWarnings("resource")
Connection conn = db.getConnection();
String sql = "select NODEID, NAME from NODES";
ps = conn.prepareStatement(sql);
- rs = ps.executeQuery();
- while (rs.next()) {
- int id = rs.getInt("NODEID");
- String name = rs.getString("NAME");
- m.put(name, id);
+ try(ResultSet rs = ps.executeQuery()) {
+ while (rs.next()) {
+ int id = rs.getInt("NODEID");
+ String name = rs.getString("NAME");
+ m.put(name, id);
+ }
}
- rs.close();
ps.close();
db.release(conn);
} catch (SQLException e) {
@@ -128,10 +128,6 @@ public abstract class NodeClass extends Syncable {
if(ps!=null){
ps.close();
}
- if(rs!=null){
- rs.close();
- }
-
} catch (SQLException e) {
intLogger.error("PROV0005 doInsert: " + e.getMessage(),e);
}