From 8b7c38f1f0b9fc156e9776584767624b13c8ed99 Mon Sep 17 00:00:00 2001 From: esobmar Date: Thu, 27 Sep 2018 11:24:27 +0100 Subject: [PATCH] Fix logging and formatting fot NetworkRoute Change-Id: I70b2f851a84630ae3ebeb13a00338e13a6921e16 Signed-off-by: Mariusz Sobucki Issue-ID: DMAAP-775 --- .../provisioning/beans/NetworkRoute.java | 24 +++++++++++----------- 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/datarouter-prov/src/main/java/org/onap/dmaap/datarouter/provisioning/beans/NetworkRoute.java b/datarouter-prov/src/main/java/org/onap/dmaap/datarouter/provisioning/beans/NetworkRoute.java index bad6f537..8264de28 100644 --- a/datarouter-prov/src/main/java/org/onap/dmaap/datarouter/provisioning/beans/NetworkRoute.java +++ b/datarouter-prov/src/main/java/org/onap/dmaap/datarouter/provisioning/beans/NetworkRoute.java @@ -44,14 +44,15 @@ import org.onap.dmaap.datarouter.provisioning.utils.DB; * @version $Id: NetworkRoute.java,v 1.2 2013/12/16 20:30:23 eby Exp $ */ public class NetworkRoute extends NodeClass implements Comparable { + private static Logger intlogger = Logger.getLogger("org.onap.dmaap.datarouter.provisioning.internal"); private final int fromnode; private final int tonode; private final int vianode; /** - * Get a set of all Network Routes in the DB. The set is sorted according to the natural sorting order - * of the routes (based on the from and to node names in each route). + * Get a set of all Network Routes in the DB. The set is sorted according to the natural sorting order of the + * routes (based on the from and to node names in each route). * * @return the sorted set */ @@ -61,8 +62,8 @@ public class NetworkRoute extends NodeClass implements Comparable DB db = new DB(); @SuppressWarnings("resource") Connection conn = db.getConnection(); - try(Statement stmt = conn.createStatement()) { - try(ResultSet rs = stmt.executeQuery("select FROMNODE, TONODE, VIANODE from NETWORK_ROUTES")) { + try (Statement stmt = conn.createStatement()) { + try (ResultSet rs = stmt.executeQuery("select FROMNODE, TONODE, VIANODE from NETWORK_ROUTES")) { while (rs.next()) { int fromnode = rs.getInt("FROMNODE"); int tonode = rs.getInt("TONODE"); @@ -127,10 +128,9 @@ public class NetworkRoute extends NodeClass implements Comparable } catch (SQLException e) { rv = false; intlogger.warn("PROV0007 doDelete: " + e.getMessage()); - intlogger.error("SQLException " + e.getMessage()); } finally { try { - if(ps!=null) { + if (ps != null) { ps.close(); } } catch (SQLException e) { @@ -157,10 +157,9 @@ public class NetworkRoute extends NodeClass implements Comparable rv = true; } catch (SQLException e) { intlogger.warn("PROV0005 doInsert: " + e.getMessage()); - intlogger.error("SQLException " + e.getMessage()); } finally { try { - if(ps!=null) { + if (ps != null) { ps.close(); } } catch (SQLException e) { @@ -185,10 +184,9 @@ public class NetworkRoute extends NodeClass implements Comparable } catch (SQLException e) { rv = false; intlogger.warn("PROV0006 doUpdate: " + e.getMessage()); - intlogger.error("SQLException " + e.getMessage()); } finally { try { - if(ps!=null) { + if (ps != null) { ps.close(); } } catch (SQLException e) { @@ -214,8 +212,9 @@ public class NetworkRoute extends NodeClass implements Comparable @Override public boolean equals(Object obj) { - if (!(obj instanceof NetworkRoute)) + if (!(obj instanceof NetworkRoute)) { return false; + } NetworkRoute on = (NetworkRoute) obj; return (fromnode == on.fromnode) && (tonode == on.tonode) && (vianode == on.vianode); } @@ -228,8 +227,9 @@ public class NetworkRoute extends NodeClass implements Comparable @Override public int compareTo(NetworkRoute o) { if (this.fromnode == o.fromnode) { - if (this.tonode == o.tonode) + if (this.tonode == o.tonode) { return this.vianode - o.vianode; + } return this.tonode - o.tonode; } return this.fromnode - o.fromnode; -- 2.16.6