Charles Chan
Committed by Gerrit Code Review

[ONOS-3194] Prevent NullPointerException

Some kind of List (e.g. ArrayList) allow the existence of null element
Add protection here in case someone call sw.sendMsg(List<OFMessage>) and pass a list with null element

Change-Id: Ida2ffbb196d2fdcb23b911365fa3c1231eab92ed
...@@ -25,7 +25,6 @@ import org.jboss.netty.channel.ChannelHandlerContext; ...@@ -25,7 +25,6 @@ import org.jboss.netty.channel.ChannelHandlerContext;
25 import org.jboss.netty.handler.codec.oneone.OneToOneEncoder; 25 import org.jboss.netty.handler.codec.oneone.OneToOneEncoder;
26 import org.projectfloodlight.openflow.protocol.OFMessage; 26 import org.projectfloodlight.openflow.protocol.OFMessage;
27 27
28 -
29 /** 28 /**
30 * Encode an openflow message for output into a ChannelBuffer, for use in a 29 * Encode an openflow message for output into a ChannelBuffer, for use in a
31 * netty pipeline. 30 * netty pipeline.
...@@ -50,7 +49,9 @@ public class OFMessageEncoder extends OneToOneEncoder { ...@@ -50,7 +49,9 @@ public class OFMessageEncoder extends OneToOneEncoder {
50 ChannelBuffer buf = ChannelBuffers.dynamicBuffer(); 49 ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
51 50
52 for (OFMessage ofm : msglist) { 51 for (OFMessage ofm : msglist) {
53 - ofm.writeTo(buf); 52 + if (ofm != null) {
53 + ofm.writeTo(buf);
54 + }
54 } 55 }
55 return buf; 56 return buf;
56 } 57 }
......