Merge "Bug 5953: Fixed NPE in FlowRemovedTranslator."
authorJozef Bacigal <jbacigal@cisco.com>
Tue, 7 Jun 2016 07:28:23 +0000 (07:28 +0000)
committerGerrit Code Review <gerrit@opendaylight.org>
Tue, 7 Jun 2016 07:28:23 +0000 (07:28 +0000)
1  2 
openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/translator/FlowRemovedTranslator.java
openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/translator/FlowRemovedV10Translator.java

index 4ab88331e3a1385a320e2ac8f3364cd919689c05,8ed2f223eb6cde20ad14ffaa585878b48580724e..4aa08b00288f215fe1ec111544d5600e9e025941
@@@ -7,6 -7,7 +7,6 @@@
   */
  package org.opendaylight.openflowplugin.impl.translator;
  
 -import org.opendaylight.openflowplugin.api.openflow.device.DeviceContext;
  import org.opendaylight.openflowplugin.api.openflow.device.DeviceState;
  import org.opendaylight.openflowplugin.api.openflow.device.MessageTranslator;
  import org.opendaylight.openflowplugin.api.openflow.md.util.OpenflowVersion;
@@@ -29,7 -30,7 +29,7 @@@ public class FlowRemovedTranslator impl
                  .setCookie(new FlowCookie(input.getCookie()))
                  .setNode(new NodeRef(deviceState.getNodeInstanceIdentifier()))
                  .setPriority(input.getPriority())
-                 .setTableId(input.getTableId().getValue().shortValue());
+                 .setTableId(translateTableId(input));
  
          return flowRemovedBld.build();
      }
          return MatchConvertorImpl.fromOFMatchToSALMatch(flowRemoved.getMatch(),
                  deviceState.getFeatures().getDatapathId(), OpenflowVersion.OF13);
      }
+     /**
+      * Translate the table ID in the FLOW_REMOVED message to SAL table ID.
+      *
+      * @param flowRemoved  FLOW_REMOVED message.
+      * @return  SAL table ID.
+      */
+     protected Short translateTableId(FlowRemoved flowRemoved) {
+         return flowRemoved.getTableId().getValue().shortValue();
+     }
  }
index d951273edaff8fafbe4073c0892e4c37ad8a1a30,e684f857a249948aa4259afeee5a68fa6390d450..23efec2ed636a1c5f06feb76987e7b5278c901e1
@@@ -8,6 -8,7 +8,6 @@@
  
  package org.opendaylight.openflowplugin.impl.translator;
  
 -import org.opendaylight.openflowplugin.api.openflow.device.DeviceContext;
  import org.opendaylight.openflowplugin.api.openflow.device.DeviceState;
  import org.opendaylight.openflowplugin.api.openflow.md.util.OpenflowVersion;
  import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.match.MatchConvertorImpl;
@@@ -24,4 -25,15 +24,15 @@@ public class FlowRemovedV10Translator e
          return MatchConvertorImpl.fromOFMatchV10ToSALMatch(flowRemoved.getMatchV10(),
                  deviceState.getFeatures().getDatapathId(), OpenflowVersion.OF10);
      }
+     /**
+      * Always returns zero because OF10 FLOW_REMOVED doesn't contain table ID.
+      *
+      * @param flowRemoved  FLOW_REMOVED message.
+      * @return  Zero.
+      */
+     @Override
+     protected Short translateTableId(FlowRemoved flowRemoved) {
+         return Short.valueOf((short)0);
+     }
  }