fix some sonar issues 28/35628/1
authorMohamed El-Serngawy <melserngawy@inocybe.com>
Wed, 24 Feb 2016 15:42:16 +0000 (10:42 -0500)
committerMohamed El-Serngawy <melserngawy@inocybe.ca>
Wed, 2 Mar 2016 22:04:20 +0000 (22:04 +0000)
Change-Id: Ife82f0f7d1be642ff903d2c74eed1e6e30270de7
Signed-off-by: Mohamed El-Serngawy <melserngawy@inocybe.com>
(cherry picked from commit 223c0439b1f6aaf7141691d6d232bb65110b84df)

impl/src/main/java/org/opendaylight/unimgr/utils/MdsalUtils.java
impl/src/main/java/org/opendaylight/unimgr/utils/OvsdbUtils.java
impl/src/main/java/org/opendaylight/unimgr/utils/UniUtils.java
impl/src/test/java/org/opendaylight/unimgr/utils/OvsdbUtilsTest.java

index 23595cb58c200dba6a51e22fc353e6520c274e8d..74bc6fc9ca0176490f198fb95a7c4aecf324f7fd 100644 (file)
@@ -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();
     }
index 207a8d4e635ba128115f7283bf82cda315b548a8..41ad77de616bd5a84947462c04c1ef8d6e0e6cdb 100644 (file)
@@ -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<Void, TransactionCommitFailedException> 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<Void, TransactionCommitFailedException> 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<Void, TransactionCommitFailedException> 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<Void, TransactionCommitFailedException> 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);
     }
index 64f5995078768e93c9fe9230c420085027b2e296..becaeaf7916839e71a9f07e9a64baaebf8f7f46a 100644 (file)
@@ -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;
     }
index 40d534aab8765fef20b731107189d2f5d6ac4677..fa51dd0e209726a6ec86f1692109a32510744298 100644 (file)
@@ -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<Void, TransactionCommitFailedException> mockCheckedFuture = mock(CheckedFuture.class);
         when(transaction.submit()).thenReturn(mockCheckedFuture);
         assertEquals(mockCheckedFuture, OvsdbUtils.deleteTerminationPoint(dataBroker, terminationPoint, ovsdbNode));