Bug 3635 - fix npe when device disconnects during handshake 20/22520/1
authorMartin Bobak <mbobak@cisco.com>
Tue, 9 Jun 2015 08:37:55 +0000 (10:37 +0200)
committermichal rehak <mirehak@cisco.com>
Sat, 13 Jun 2015 11:59:37 +0000 (11:59 +0000)
Change-Id: Ia92660d630ddbcefdfd37e887ab896c2550e88cc
Signed-off-by: Martin Bobak <mbobak@cisco.com>
(cherry picked from commit 3c0d578f2001e1114e6da8df8dfaf437d14f2a7a)

openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/connection/ConnectionContextImpl.java

index 31603a77cee28e98ed770eb2e596f40996e8f8e6..cbd5d0440ef293330f05aca3f114c7f5a4a65af7 100644 (file)
@@ -89,7 +89,11 @@ public class ConnectionContextImpl implements ConnectionContext {
 
     @Override
     public void closeConnection(boolean propagate) {
-        SessionStatistics.countEvent(nodeId.toString(), SessionStatistics.ConnectionStatus.CONNECTION_DISCONNECTED_BY_OFP);
+        if (null == nodeId){
+            SessionStatistics.countEvent(connectionAdapter.getRemoteAddress().toString(), SessionStatistics.ConnectionStatus.CONNECTION_DISCONNECTED_BY_OFP);
+        } else {
+            SessionStatistics.countEvent(nodeId.toString(), SessionStatistics.ConnectionStatus.CONNECTION_DISCONNECTED_BY_OFP);
+        }
         final BigInteger datapathId = featuresReply != null ? featuresReply.getDatapathId() : BigInteger.ZERO;
         LOG.debug("Actively closing connection: {}, datapathId:{}.",
                 connectionAdapter.getRemoteAddress(), datapathId);
@@ -107,7 +111,11 @@ public class ConnectionContextImpl implements ConnectionContext {
 
     @Override
     public void onConnectionClosed() {
-        SessionStatistics.countEvent(nodeId.toString(), SessionStatistics.ConnectionStatus.CONNECTION_DISCONNECTED_BY_DEVICE);
+        if (null == nodeId){
+            SessionStatistics.countEvent(connectionAdapter.getRemoteAddress().toString(), SessionStatistics.ConnectionStatus.CONNECTION_DISCONNECTED_BY_DEVICE);
+        } else {
+            SessionStatistics.countEvent(nodeId.toString(), SessionStatistics.ConnectionStatus.CONNECTION_DISCONNECTED_BY_DEVICE);
+        }
         connectionState = ConnectionContext.CONNECTION_STATE.RIP;
 
         final InetSocketAddress remoteAddress = connectionAdapter.getRemoteAddress();