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;
import org.jboss.netty.handler.codec.oneone.OneToOneEncoder;
import org.projectfloodlight.openflow.protocol.OFMessage;
/**
* Encode an openflow message for output into a ChannelBuffer, for use in a
* netty pipeline.
......@@ -50,7 +49,9 @@ public class OFMessageEncoder extends OneToOneEncoder {
ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
for (OFMessage ofm : msglist) {
ofm.writeTo(buf);
if (ofm != null) {
ofm.writeTo(buf);
}
}
return buf;
}
......