aboutsummaryrefslogtreecommitdiffstats
path: root/datarouter-prov/src/main
diff options
context:
space:
mode:
authorAmaresh Kumar <kamaresh@in.ibm.com>2018-09-04 18:40:19 +0530
committerAmaresh Kumar <kamaresh@in.ibm.com>2018-09-04 18:40:26 +0530
commit94ff05ac011b5ec80142a4c9a084415bb21c6aed (patch)
treeda5b6219e01933a9fa47d96bbe46a8c746a710e3 /datarouter-prov/src/main
parenta1cc0279360b09663c1b59fd0b89a1c2e081dfbd (diff)
Fixed Sonar Issues in LogRecord.java
https://sonar.onap.org/project/issues?id=org.onap.dmaap.datarouter%3Aparent&open=AWHFaQo_EU5FCDfKtnZ4&resolved=false&severities=BLOCKER&types=BUG Issue-ID: DMAAP-697 Change-Id: I57f79eeafb839498231f2550101b9f843b3bb20f Signed-off-by: Amaresh Kumar <kamaresh@in.ibm.com>
Diffstat (limited to 'datarouter-prov/src/main')
-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 {