Fix a guaranteed NPE 85/35785/2
authorRobert Varga <rovarga@cisco.com>
Fri, 4 Mar 2016 13:31:08 +0000 (14:31 +0100)
committerRobert Varga <rovarga@cisco.com>
Fri, 4 Mar 2016 13:34:45 +0000 (14:34 +0100)
If we fail to decode a packet, we will end up causing a NPE in
statistics. Use the packetIn class for that instead.

Change-Id: Ib53ca939ee4a08319c2595d560bfdd99c013eba2
Signed-off-by: Robert Varga <rovarga@cisco.com>
openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/device/DeviceContextImpl.java

index f5ad89c479a7e0fb597ce8762673f0d04615293f..524e223f45622fab0d1b49984cf01fc0b05f61aa 100644 (file)
@@ -29,7 +29,6 @@ import java.util.Map;
 import java.util.concurrent.ConcurrentHashMap;
 import javax.annotation.CheckForNull;
 import javax.annotation.Nonnull;
-import javax.annotation.Nullable;
 import org.opendaylight.controller.md.sal.binding.api.DataBroker;
 import org.opendaylight.controller.md.sal.binding.api.NotificationPublishService;
 import org.opendaylight.controller.md.sal.binding.api.NotificationService;
@@ -465,7 +464,7 @@ public class DeviceContextImpl implements DeviceContext, ExtensionConverterProvi
 
         if (packetReceived == null) {
             LOG.debug("Received a null packet from switch {}", connectionAdapter.getRemoteAddress());
-            messageSpy.spyMessage(packetReceived.getImplementedInterface(), MessageSpy.STATISTIC_GROUP.FROM_SWITCH_TRANSLATE_SRC_FAILURE);
+            messageSpy.spyMessage(packetInMessage.getImplementedInterface(), MessageSpy.STATISTIC_GROUP.FROM_SWITCH_TRANSLATE_SRC_FAILURE);
             return;
         } else {
             messageSpy.spyMessage(packetReceived.getImplementedInterface(), MessageSpy.STATISTIC_GROUP.FROM_SWITCH_TRANSLATE_OUT_SUCCESS);