From f0de6e9b39532de70da2165c6bc259e9e7a0024f Mon Sep 17 00:00:00 2001 From: Mohamed El-Serngawy Date: Wed, 24 Feb 2016 10:42:16 -0500 Subject: [PATCH] fix some sonar issues Change-Id: Ife82f0f7d1be642ff903d2c74eed1e6e30270de7 Signed-off-by: Mohamed El-Serngawy (cherry picked from commit 223c0439b1f6aaf7141691d6d232bb65110b84df) --- .../opendaylight/unimgr/utils/MdsalUtils.java | 8 +++--- .../opendaylight/unimgr/utils/OvsdbUtils.java | 28 ++++++++----------- .../opendaylight/unimgr/utils/UniUtils.java | 2 +- .../unimgr/utils/OvsdbUtilsTest.java | 2 +- 4 files changed, 18 insertions(+), 22 deletions(-) diff --git a/impl/src/main/java/org/opendaylight/unimgr/utils/MdsalUtils.java b/impl/src/main/java/org/opendaylight/unimgr/utils/MdsalUtils.java index 23595cb5..74bc6fc9 100644 --- a/impl/src/main/java/org/opendaylight/unimgr/utils/MdsalUtils.java +++ b/impl/src/main/java/org/opendaylight/unimgr/utils/MdsalUtils.java @@ -79,7 +79,7 @@ public class MdsalUtils { try { return nodeFuture.checkedGet(); } catch (final ReadFailedException e) { - LOG.info("Unable to read node with Iid {}", nodeIid); + LOG.error("Unable to read node with Iid {}", nodeIid, e); } return Optional.absent(); } @@ -101,7 +101,7 @@ public class MdsalUtils { transaction.submit().checkedGet(); result = true; } catch (final TransactionCommitFailedException e) { - LOG.error("Unable to remove node with Iid {} from store {}.", genericNode, store); + LOG.error("Unable to remove node with Iid {} from store {}", genericNode, store, e); } return result; } @@ -122,7 +122,7 @@ public class MdsalUtils { try { return linkFuture.checkedGet(); } catch (final ReadFailedException e) { - LOG.info("Unable to read node with Iid {}", linkIid); + LOG.info("Unable to read node with Iid {}", linkIid, e); } return Optional.absent(); } @@ -144,7 +144,7 @@ public class MdsalUtils { try { return nodeFuture.checkedGet(); } catch (final ReadFailedException e) { - LOG.info("Unable to read node with Iid {}", nodeIid); + LOG.info("Unable to read node with Iid {}", nodeIid, e); } return Optional.absent(); } diff --git a/impl/src/main/java/org/opendaylight/unimgr/utils/OvsdbUtils.java b/impl/src/main/java/org/opendaylight/unimgr/utils/OvsdbUtils.java index 207a8d4e..41ad77de 100644 --- a/impl/src/main/java/org/opendaylight/unimgr/utils/OvsdbUtils.java +++ b/impl/src/main/java/org/opendaylight/unimgr/utils/OvsdbUtils.java @@ -295,7 +295,7 @@ public class OvsdbUtils { transaction.submit(); LOG.info("Created and submitted a new OVSDB node {}", nodeData.getNodeId()); } catch (final Exception e) { - LOG.error("Exception while creating OvsdbNodeAugmentation, " + "Uni is null. Node Id: {}", ovsdbNodeId); + LOG.error("Exception while creating OvsdbNodeAugmentation, Uni is null. Node Id: {}", ovsdbNodeId, e); } } @@ -324,7 +324,7 @@ public class OvsdbUtils { LOG.info("Created and submitted a new OVSDB node {}", nodeData.getNodeId()); return nodeData; } catch (final Exception e) { - LOG.error("Exception while creating OvsdbNodeAugmentation, " + "Uni is null. Node Id: {}", ovsdbNodeId); + LOG.error("Exception while creating OvsdbNodeAugmentation, Uni is null. Node Id: {}", ovsdbNodeId, e); } return null; } @@ -374,11 +374,11 @@ public class OvsdbUtils { try { Thread.sleep(UnimgrConstants.OVSDB_UPDATE_TIMEOUT); } catch (final InterruptedException e) { - LOG.warn("Interrupted while waiting after OVSDB node augmentation {} {}", ovsdbNodeId, e); + LOG.warn("Interrupted while waiting after OVSDB node augmentation {}", ovsdbNodeId, e); } try { future.checkedGet(); - LOG.trace("Update qos and queues to ovsdb for node {} {}", ovsdbNodeId, ovsdbNodeAugmentationIid); + LOG.trace("Update qos and queues to ovsdb for node {} {}", ovsdbNodeId, ovsdbNodeAugmentationIid); } catch (final TransactionCommitFailedException e) { LOG.warn("Failed to put {} ", ovsdbNodeAugmentationIid, e); } @@ -493,7 +493,7 @@ public class OvsdbUtils { final CheckedFuture future = transaction.submit(); try { future.checkedGet(); - LOG.info("Update qos-entries to ovsdb for node {} {}", ovsdbNodeId, queueIid); + LOG.info("Update qos-entries to ovsdb for node {} {}", ovsdbNodeId, queueIid); } catch (final TransactionCommitFailedException e) { LOG.warn("Failed to put {} ", queueIid, e); } @@ -554,9 +554,9 @@ public class OvsdbUtils { final CheckedFuture future = transaction.submit(); try { future.checkedGet(); - LOG.info("Update qos-entries max-rate to ovsdb for node {} {}", ovsdbNodeId, qosOtherConfigIid);; + LOG.info("Update qos-entries max-rate to ovsdb for node {} {}", ovsdbNodeId, qosOtherConfigIid);; } catch (final TransactionCommitFailedException e) { - LOG.warn("Failed to put {} ", qosOtherConfigIid, e); + LOG.warn("Failed to put {}", qosOtherConfigIid, e); } } @@ -583,7 +583,7 @@ public class OvsdbUtils { final CheckedFuture future = transaction.submit(); try { future.checkedGet(); - LOG.info("Update queues max-rate to ovsdb for node {} {}", ovsdbNodeId, queuesOtherConfigIid);; + LOG.info("Update queues max-rate to ovsdb for node {} {}", ovsdbNodeId, queuesOtherConfigIid);; } catch (final TransactionCommitFailedException e) { LOG.warn("Failed to put {} ", queuesOtherConfigIid, e); } @@ -756,9 +756,7 @@ public class OvsdbUtils { final WriteTransaction transaction = dataBroker.newWriteOnlyTransaction(); transaction.delete(LogicalDatastoreType.CONFIGURATION, terminationPointPath); transaction.delete(LogicalDatastoreType.OPERATIONAL, terminationPointPath); - transaction.submit(); - final CheckedFuture future = transaction.submit(); - return future; + return transaction.submit(); } @@ -867,8 +865,7 @@ public class OvsdbUtils { final Node ovsdbNode = node.get(); final OvsdbNodeAugmentation ovsdbNodeAugmentation = ovsdbNode .getAugmentation(OvsdbNodeAugmentation.class); - final ConnectionInfo connectionInfo = ovsdbNodeAugmentation.getConnectionInfo(); - return connectionInfo; + return ovsdbNodeAugmentation.getConnectionInfo(); } else { return null; } @@ -883,10 +880,9 @@ public class OvsdbUtils { try { ip = InetAddress.getLocalHost().getHostAddress(); final Ipv4Address ipv4 = new Ipv4Address(ip); - final IpAddress ipAddress = new IpAddress(ipv4); - return ipAddress; + return new IpAddress(ipv4); } catch (final UnknownHostException e) { - LOG.info("Unable to retrieve controller's ip address, using loopback."); + LOG.info("Unable to retrieve controller's ip address, using loopback. {}", e); } return new IpAddress(UnimgrConstants.LOCAL_IP); } diff --git a/impl/src/main/java/org/opendaylight/unimgr/utils/UniUtils.java b/impl/src/main/java/org/opendaylight/unimgr/utils/UniUtils.java index 64f59950..becaeaf7 100644 --- a/impl/src/main/java/org/opendaylight/unimgr/utils/UniUtils.java +++ b/impl/src/main/java/org/opendaylight/unimgr/utils/UniUtils.java @@ -74,7 +74,7 @@ public class UniUtils { result = true; LOG.info("Created and submitted a new Uni node {}", nodeData.getNodeId()); } catch (final Exception e) { - LOG.error("Exception while creating Uni Node" + "Uni Node Id: {}", uniNodeId); + LOG.error("Exception while creating Uni Node, Uni Node Id: {}", uniNodeId, e); } return result; } diff --git a/impl/src/test/java/org/opendaylight/unimgr/utils/OvsdbUtilsTest.java b/impl/src/test/java/org/opendaylight/unimgr/utils/OvsdbUtilsTest.java index 40d534aa..fa51dd0e 100644 --- a/impl/src/test/java/org/opendaylight/unimgr/utils/OvsdbUtilsTest.java +++ b/impl/src/test/java/org/opendaylight/unimgr/utils/OvsdbUtilsTest.java @@ -422,7 +422,7 @@ public class OvsdbUtilsTest { OvsdbUtils.deleteTerminationPoint(dataBroker, terminationPoint, ovsdbNode); verify(transaction,times(2)).delete(any(LogicalDatastoreType.class), any(InstanceIdentifier.class)); - verify(transaction,times(2)).submit(); + verify(transaction,times(1)).submit(); CheckedFuture mockCheckedFuture = mock(CheckedFuture.class); when(transaction.submit()).thenReturn(mockCheckedFuture); assertEquals(mockCheckedFuture, OvsdbUtils.deleteTerminationPoint(dataBroker, terminationPoint, ovsdbNode)); -- 2.36.6