Fix NPE in OvsdbConnectionService updateConfigParameter 75/52975/2
authorMichael Vorburger <vorburger@redhat.com>
Tue, 7 Mar 2017 23:41:34 +0000 (00:41 +0100)
committerStephen Kitt <skitt@redhat.com>
Wed, 8 Mar 2017 08:58:54 +0000 (08:58 +0000)
seen in SingleFeatureTest (SFT) running under Karaf 4

maybe under Karaf 3 this was never called with null, but under 4 it is

Change-Id: I886ccf99ef4be85b6e103d69fa457ec4a0dab4d9
Signed-off-by: Michael Vorburger <vorburger@redhat.com>
library/impl/src/main/java/org/opendaylight/ovsdb/lib/impl/OvsdbConnectionService.java

index 8ca188a5a9d48aae6112ce4174d1447956d8c963..fe473b9b3899c4fdd2c1a4f46bc8143f4e1bb872 100644 (file)
@@ -201,12 +201,9 @@ public class OvsdbConnectionService implements AutoCloseable, OvsdbConnection {
 
     private void notifyAlreadyExistingConnectionsToListener(final OvsdbConnectionListener listener) {
         for (final OvsdbClient client : getConnections()) {
-            connectionNotifierService.submit(new Runnable() {
-                @Override
-                public void run() {
-                    LOG.trace("Connection {} notified to listener {}", client.getConnectionInfo(), listener);
-                    listener.connected(client);
-                }
+            connectionNotifierService.submit(() -> {
+                LOG.trace("Connection {} notified to listener {}", client.getConnectionInfo(), listener);
+                listener.connected(client);
             });
         }
     }
@@ -475,13 +472,10 @@ public class OvsdbConnectionService implements AutoCloseable, OvsdbConnection {
             executorService.schedule(new HandleNewPassiveSslRunner(channel, sslHandler),
                     retryPeriod, TimeUnit.MILLISECONDS);
         } else {
-            executorService.execute(new Runnable() {
-                @Override
-                public void run() {
-                    OvsdbClient client = getChannelClient(channel, ConnectionType.PASSIVE,
-                        SocketConnectionType.NON_SSL);
-                    handleNewPassiveConnection(client);
-                }
+            executorService.execute(() -> {
+                OvsdbClient client = getChannelClient(channel, ConnectionType.PASSIVE,
+                    SocketConnectionType.NON_SSL);
+                handleNewPassiveConnection(client);
             });
         }
     }
@@ -535,12 +529,9 @@ public class OvsdbConnectionService implements AutoCloseable, OvsdbConnection {
     public static void notifyListenerForPassiveConnection(final OvsdbClient client) {
         client.setConnectionPublished(true);
         for (final OvsdbConnectionListener listener : connectionListeners) {
-            connectionNotifierService.submit(new Runnable() {
-                @Override
-                public void run() {
-                    LOG.trace("Connection {} notified to listener {}", client.getConnectionInfo(), listener);
-                    listener.connected(client);
-                }
+            connectionNotifierService.submit(() -> {
+                LOG.trace("Connection {} notified to listener {}", client.getConnectionInfo(), listener);
+                listener.connected(client);
             });
         }
     }
@@ -585,8 +576,8 @@ public class OvsdbConnectionService implements AutoCloseable, OvsdbConnection {
     }
 
     public void updateConfigParameter(Map<String, Object> configParameters) {
-        LOG.debug("Config parameters received : {}", configParameters.entrySet());
         if (configParameters != null && !configParameters.isEmpty()) {
+            LOG.debug("Config parameters received : {}", configParameters.entrySet());
             for (Map.Entry<String, Object> paramEntry : configParameters.entrySet()) {
                 if (paramEntry.getKey().equalsIgnoreCase(OVSDB_RPC_TASK_TIMEOUT_PARAM)) {
                     setOvsdbRpcTaskTimeout(Integer.parseInt((String)paramEntry.getValue()));