Added validation
[openflowjava.git] / openflow-protocol-impl / src / main / java / org / opendaylight / openflowjava / protocol / impl / util / ActionsSerializer.java
index c7e07ee716f179494a941388af99c22eba5a4fa3..e99d204cb929558794d11a0f62ad60b857d690a1 100644 (file)
@@ -237,11 +237,15 @@ public abstract class ActionsSerializer {
     \r
     private static void encodeCommonEthertype(Action action, ByteBuf outBuffer) {\r
         final byte LENGTH_OF_ETHERTYPE_ACTION = 8;\r
-        final byte ETHERTYPE_ACTION_PADDING = 2;\r
-        outBuffer.writeShort(LENGTH_OF_ETHERTYPE_ACTION);\r
+        final byte ETHERTYPE_ACTION_PADDING = 2;        \r
         EthertypeAction ethertype = action.getAugmentation(EthertypeAction.class);\r
-        outBuffer.writeShort(ethertype.getEthertype().getValue());\r
-        ByteBufUtils.padBuffer(ETHERTYPE_ACTION_PADDING, outBuffer);\r
+        \r
+        if (null != ethertype && null != ethertype.getEthertype()) {\r
+            outBuffer.writeShort(LENGTH_OF_ETHERTYPE_ACTION);\r
+            \r
+            outBuffer.writeShort(ethertype.getEthertype().getValue());\r
+            ByteBufUtils.padBuffer(ETHERTYPE_ACTION_PADDING, outBuffer);\r
+        }\r
     }\r
     \r
     /**\r