summaryrefslogtreecommitdiffstats
path: root/datarouter-prov/src
diff options
context:
space:
mode:
authorRam Koya <rk541m@att.com>2018-09-04 15:41:50 +0000
committerGerrit Code Review <gerrit@onap.org>2018-09-04 15:41:50 +0000
commitac12c63cc36197e569fba1c54e45b1b999384321 (patch)
tree1a3294ab0ae98c7dcd0fc62a0dc617de80fff9d9 /datarouter-prov/src
parentc7ddeaab4dd317de91aac32e07404a2ed4ac6567 (diff)
parent94ff05ac011b5ec80142a4c9a084415bb21c6aed (diff)
Merge "Fixed Sonar Issues in LogRecord.java"
Diffstat (limited to 'datarouter-prov/src')
-rw-r--r--datarouter-prov/src/main/java/org/onap/dmaap/datarouter/provisioning/beans/LogRecord.java30
1 files changed, 15 insertions, 15 deletions
diff --git a/datarouter-prov/src/main/java/org/onap/dmaap/datarouter/provisioning/beans/LogRecord.java b/datarouter-prov/src/main/java/org/onap/dmaap/datarouter/provisioning/beans/LogRecord.java
index 1853ee30..70b8e6a0 100644
--- a/datarouter-prov/src/main/java/org/onap/dmaap/datarouter/provisioning/beans/LogRecord.java
+++ b/datarouter-prov/src/main/java/org/onap/dmaap/datarouter/provisioning/beans/LogRecord.java
@@ -59,23 +59,23 @@ public class LogRecord extends BaseLogRecord {
Connection conn = null;
try {
conn = db.getConnection();
- Statement stmt = conn.createStatement();
- Iterator<Long[]> iter = bs.getRangeIterator();
- PreparedStatement ps = conn.prepareStatement(sql);
- while (iter.hasNext()) {
- Long[] n = iter.next();
- ps.setLong(1, n[0]);
- ps.setLong(2, n[1]);
- ResultSet rs = ps.executeQuery();
- while (rs.next()) {
- LogRecord lr = new LogRecord(rs);
- os.write(lr.toString().getBytes());
+ try(Statement stmt = conn.createStatement()) {
+ Iterator<Long[]> iter = bs.getRangeIterator();
+ try(PreparedStatement ps = conn.prepareStatement(sql)) {
+ while (iter.hasNext()) {
+ Long[] n = iter.next();
+ ps.setLong(1, n[0]);
+ ps.setLong(2, n[1]);
+ try(ResultSet rs = ps.executeQuery()) {
+ while (rs.next()) {
+ LogRecord lr = new LogRecord(rs);
+ os.write(lr.toString().getBytes());
+ }
+ ps.clearParameters();
+ }
+ }
}
- rs.close();
- ps.clearParameters();
}
- ps.close();
- stmt.close();
} catch (SQLException e) {
e.printStackTrace();
} finally {