Bug 5953: Fixed NPE in FlowRemovedTranslator.
[openflowplugin.git] / openflowplugin-impl / src / main / java / org / opendaylight / openflowplugin / impl / translator / FlowRemovedTranslator.java
index 956389a10362294c029f8d2901c5b707538d7b35..8ed2f223eb6cde20ad14ffaa585878b48580724e 100644 (file)
@@ -30,7 +30,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();
     }
@@ -39,4 +39,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();
+    }
 }