BUG-612 : defensive parser for LSPA 65/8365/5
authorDana Kutenicsova <dkutenic@cisco.com>
Thu, 26 Jun 2014 12:07:41 +0000 (14:07 +0200)
committerDana Kutenicsova <dkutenic@cisco.com>
Thu, 26 Jun 2014 12:23:44 +0000 (14:23 +0200)
Change-Id: If6cec792bb995c4a6d44709b3755616c27316b2c
Signed-off-by: Dana Kutenicsova <dkutenic@cisco.com>
pcep/impl/src/main/java/org/opendaylight/protocol/pcep/impl/object/PCEPLspaObjectParser.java

index ee0057d6bb405d0f0c1ca037fd1841a4d7a4dd44..184c13eb973a05545e636a702de378f0cb3f32e1 100644 (file)
@@ -80,11 +80,31 @@ public class PCEPLspaObjectParser extends AbstractObjectWithTlvsParser<TlvsBuild
         Preconditions.checkArgument(object instanceof Lspa, "Wrong instance of PCEPObject. Passed %s. Needed LspaObject.", object.getClass());
         final Lspa lspaObj = (Lspa) object;
         final ByteBuf body = Unpooled.buffer();
-        body.writeInt(lspaObj.getExcludeAny().getValue().intValue());
-        body.writeInt(lspaObj.getIncludeAny().getValue().intValue());
-        body.writeInt(lspaObj.getIncludeAll().getValue().intValue());
-        body.writeByte(lspaObj.getSetupPriority());
-        body.writeByte(lspaObj.getHoldPriority());
+        if (lspaObj.getExcludeAny() != null) {
+            body.writeInt(lspaObj.getExcludeAny().getValue().intValue());
+        } else {
+            body.writeZero(Integer.SIZE / Byte.SIZE);
+        }
+        if (lspaObj.getIncludeAny() != null) {
+            body.writeInt(lspaObj.getIncludeAny().getValue().intValue());
+        } else {
+            body.writeZero(Integer.SIZE / Byte.SIZE);
+        }
+        if (lspaObj.getIncludeAll() != null) {
+            body.writeInt(lspaObj.getIncludeAll().getValue().intValue());
+        } else {
+            body.writeZero(Integer.SIZE / Byte.SIZE);
+        }
+        if (lspaObj.getSetupPriority() != null) {
+            body.writeByte(lspaObj.getSetupPriority());
+        } else {
+            body.writeZero(1);
+        }
+        if (lspaObj.getHoldPriority() != null) {
+            body.writeByte(lspaObj.getHoldPriority());
+        } else {
+            body.writeZero(1);
+        }
         final BitSet flags = new BitSet(FLAGS_F_LENGTH * Byte.SIZE);
         if (lspaObj.isLocalProtectionDesired() != null) {
             flags.set(L_FLAG_OFFSET, lspaObj.isLocalProtectionDesired());