diff options
author | Ram Koya <rk541m@att.com> | 2018-09-04 15:41:50 +0000 |
---|---|---|
committer | Gerrit Code Review <gerrit@onap.org> | 2018-09-04 15:41:50 +0000 |
commit | ac12c63cc36197e569fba1c54e45b1b999384321 (patch) | |
tree | 1a3294ab0ae98c7dcd0fc62a0dc617de80fff9d9 /datarouter-prov/src | |
parent | c7ddeaab4dd317de91aac32e07404a2ed4ac6567 (diff) | |
parent | 94ff05ac011b5ec80142a4c9a084415bb21c6aed (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.java | 30 |
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 {
|