Buggy code:
public class ACAMPagent implements IOFMessageListener , IFloodlightModule { protected static Logger logger ; protected IFloodlightProviderService floodlightProvider ; private static void sendMessage ( IOFSwitch sw , OFPort inPort , MacAddress srcMac , MacAddress dstMac , IPv4Address srcAddress , IPv4Address dstAddress , TransportPort srcPort , TransportPort dstPort , byte [ ] acamp_bytes ) { } @ Override public String getName ( ) { } @ Override public boolean isCallbackOrderingPrereq ( OFType type , String name ) { } @ Override public boolean isCallbackOrderingPostreq ( OFType type , String name ) { } @ Override public Collection < Class < ? extends IFloodlightService > > getModuleServices ( ) { } @ Override public Map < Class < ? extends IFloodlightService > , IFloodlightService > getServiceImpls ( ) { } @ Override public Collection < Class < ? extends IFloodlightService > > getModuleDependencies ( ) { } @ Override public void init ( FloodlightModuleContext context ) throws FloodlightModuleException { } @ Override public void startUp ( FloodlightModuleContext context ) throws FloodlightModuleException { } @ Override public Command receive ( IOFSwitch sw , OFMessage msg , FloodlightContext cntx ) { switch ( msg . getType ( ) ) { case PACKET_IN : { OFPacketIn myPacketIn = ( ( OFPacketIn ) ( msg ) ) ; OFPort inPort = ( ( myPacketIn . getVersion ( ) . compareTo ( OF_12 ) ) < 0 ) ? myPacketIn . getInPort ( ) : myPacketIn . getMatch ( ) . get ( IN_PORT ) ; ACAMPagent . logger . info ( ( "A<seq2seq4repair_space>Packet-In<seq2seq4repair_space>Message<seq2seq4repair_space>has<seq2seq4repair_space>arrive<seq2seq4repair_space>Controller<seq2seq4repair_space>which<seq2seq4repair_space>comes<seq2seq4repair_space>from:" + ( "{}" + "<seq2seq4repair_space>Port:{}" ) ) , sw . getId ( ) . toString ( ) , inPort . toString ( ) ) ; Ethernet eth = bcStore . get ( cntx , CONTEXT_PI_PAYLOAD ) ; MacAddress srcMacAddress = eth . getSourceMACAddress ( ) ; MacAddress dstMacAddress = eth . getDestinationMACAddress ( ) ; IPv4 ipv4 = ( ( IPv4 ) ( eth . getPayload ( ) ) ) ; IPv4Address srcIpAddr = ipv4 . getSourceAddress ( ) ; IPv4Address dstIpAddr = ipv4 . getDestinationAddress ( ) ; if ( ipv4 . getProtocol ( ) . equals ( UDP ) ) { net . floodlightcontroller . packet . UDP udp = ( ( net . floodlightcontroller . packet . UDP ) ( ipv4 . getPayload ( ) ) ) ; TransportPort srcPort = udp . getSourcePort ( ) ; TransportPort dstPort = udp . getDestinationPort ( ) ; ACAMP recv = new ACAMP ( ) ; <START_BUG> byte [ ] recvData = udp . serialize ( ) ; <END_BUG> try { recv . deserialize ( recvData , 0 , recvData . length ) ; } catch ( PacketParsingException e ) { e . printStackTrace ( ) ; } ACAMP acmap = new ACAMP ( ) ; ACAMPMsgEle msgEle = new ACAMPMsgEle ( ) ; TestMsgEle testMsgEle = new TestMsgEle ( ) ; testMsgEle . setTypeValue ( 5656 ) ; msgEle . setMessageElementType ( ( ( short ) ( RESULT_CODE ) ) ) . setPayload ( testMsgEle ) ; ACAMPMsgEle msgEle2 = new ACAMPMsgEle ( ) ; TestMsgEle testMsgEle2 = new TestMsgEle ( ) ; testMsgEle2 . setTypeValue ( 5656 ) ; msgEle2 . setMessageElementType ( ( ( short ) ( RESULT_CODE ) ) ) . setPayload ( testMsgEle2 ) ; ACAMPData acampData = new ACAMPData ( ) ; acampData . addMessageElement ( msgEle ) ; acampData . addMessageElement ( msgEle2 ) ; acmap . setVersion ( ( ( byte ) ( 10 ) ) ) . setType ( ( ( byte ) ( 11 ) ) ) . setAPID ( ( ( short ) ( 12 ) ) ) . setSequenceNumber ( ( ( int ) ( 88888888 ) ) ) . setMessageType ( ( ( short ) ( 13 ) ) ) . setPayload ( acampData ) ; byte [ ] data = acmap . serialize ( ) ; ACAMPagent . sendMessage ( sw , inPort , dstMacAddress , srcMacAddress , dstIpAddr , srcIpAddr , dstPort , srcPort , data ) ; } break ; } default : break ; } return Command . STOP ; } }

Fix:
byte [ ] recvData = udp . getPayload ( ) . serialize ( ) ;