Merge "Bug 5953: Fixed NPE in FlowRemovedTranslator."
[openflowplugin.git] / openflowplugin-impl / src / main / java / org / opendaylight / openflowplugin / impl / translator / FlowRemovedTranslator.java
index 4ab88331e3a1385a320e2ac8f3364cd919689c05..4aa08b00288f215fe1ec111544d5600e9e025941 100644 (file)
@@ -29,7 +29,7 @@ public class FlowRemovedTranslator implements MessageTranslator<FlowRemoved, org
                 .setCookie(new FlowCookie(input.getCookie()))
                 .setNode(new NodeRef(deviceState.getNodeInstanceIdentifier()))
                 .setPriority(input.getPriority())
-                .setTableId(input.getTableId().getValue().shortValue());
+                .setTableId(translateTableId(input));
 
         return flowRemovedBld.build();
     }
@@ -38,4 +38,14 @@ public class FlowRemovedTranslator implements MessageTranslator<FlowRemoved, org
         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();
+    }
 }