Fix OPNFLWPLUG-1107 null pointer exception 89/94689/2
authorSangwook Ha <sangwook.ha@verizon.com>
Thu, 21 Jan 2021 02:19:23 +0000 (18:19 -0800)
committerRobert Varga <nite@hq.sk>
Fri, 22 Jan 2021 09:52:27 +0000 (09:52 +0000)
Check if deviceInfo is null before continue - OpenFlow channel may get
dropped before deviceInfo is available.

Change-Id: I71a2928ac52df425692dd98b455923dcddfa1d28
Signed-off-by: Sangwook Ha <sangwook.ha@verizon.com>
openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/lifecycle/ContextChainHolderImpl.java

index 96630b4193580053ab2f3ebaf01a3a9b8d85cead..a8d0362a353c64fa63b0cb9647f9f16033d1ee7c 100644 (file)
@@ -268,13 +268,15 @@ public class ContextChainHolderImpl implements ContextChainHolder, MasterChecker
     @Override
     public void onDeviceDisconnected(final ConnectionContext connectionContext) {
         final DeviceInfo deviceInfo = connectionContext.getDeviceInfo();
-        final ContextChain contextChain = contextChainMap.get(deviceInfo);
-        if (contextChain != null) {
-            if (contextChain.auxiliaryConnectionDropped(connectionContext)) {
-                LOG.info("Auxiliary connection from device {} disconnected.", deviceInfo);
-            } else {
-                LOG.info("Device {} disconnected.", deviceInfo);
-                destroyContextChain(deviceInfo);
+        if (deviceInfo != null) {
+            final ContextChain contextChain = contextChainMap.get(deviceInfo);
+            if (contextChain != null) {
+                if (contextChain.auxiliaryConnectionDropped(connectionContext)) {
+                    LOG.info("Auxiliary connection from device {} disconnected.", deviceInfo);
+                } else {
+                    LOG.info("Device {} disconnected.", deviceInfo);
+                    destroyContextChain(deviceInfo);
+                }
             }
         }
     }