ixonos / jcimd

Java CIMD (Computer Interface to Message Distribution) API
6 stars 6 forks source link

PacketSerializer deserialization fails without CIMD packet checksums #1

Closed marko-asplund closed 12 years ago

marko-asplund commented 12 years ago

Checksums are an optional feature of the CIMD 2 protocol. PacketSerializer fails when configured to work without checksums:

new PacketSerializer("ser", false);

here's a stack trace:

420  [NioProcessor-2] INFO  org.apache.mina.filter.logging.LoggingFilter  - CREATED
420  [NioProcessor-2] INFO  org.apache.mina.filter.logging.LoggingFilter  - OPENED
426  [NioProcessor-2] INFO  org.apache.mina.filter.logging.LoggingFilter  - RECEIVED: HeapBuffer[pos=0 lim=35 cap=2048: 02 30 31 3A 30 30 31 09 30 31 30 3A 73 6D 73 31...]
431  [NioProcessor-2] WARN  org.apache.mina.core.service.IoHandlerAdapter  - EXCEPTION, please implement com.ixonos.cimd.simulator.CIMDMessageHandler.exceptionCaught() for proper handling:
org.apache.mina.filter.codec.ProtocolDecoderException: java.io.IOException: Expecting 0x9 but got 0x6a (Hexdump: 02 30 31 3A 30 30 31 09 30 31 30 3A 73 6D 73 31 36 32 30 35 09 30 31 31 3A 78 69 72 75 63 38 63 6A 09 03)
        at org.apache.mina.filter.codec.ProtocolCodecFilter.messageReceived(ProtocolCodecFilter.java:251)
        at org.apache.mina.core.filterchain.DefaultIoFilterChain.callNextMessageReceived(DefaultIoFilterChain.java:434)
        at org.apache.mina.core.filterchain.DefaultIoFilterChain.access$1200(DefaultIoFilterChain.java:46)
        at org.apache.mina.core.filterchain.DefaultIoFilterChain$EntryImpl$1.messageReceived(DefaultIoFilterChain.java:796)
        at org.apache.mina.filter.logging.LoggingFilter.messageReceived(LoggingFilter.java:177)
        at org.apache.mina.core.filterchain.DefaultIoFilterChain.callNextMessageReceived(DefaultIoFilterChain.java:434)
        at org.apache.mina.core.filterchain.DefaultIoFilterChain.access$1200(DefaultIoFilterChain.java:46)
        at org.apache.mina.core.filterchain.DefaultIoFilterChain$EntryImpl$1.messageReceived(DefaultIoFilterChain.java:796)
        at org.apache.mina.core.filterchain.IoFilterAdapter.messageReceived(IoFilterAdapter.java:119)
        at org.apache.mina.core.filterchain.DefaultIoFilterChain.callNextMessageReceived(DefaultIoFilterChain.java:434)
        at org.apache.mina.core.filterchain.DefaultIoFilterChain.fireMessageReceived(DefaultIoFilterChain.java:426)
        at org.apache.mina.core.polling.AbstractPollingIoProcessor.read(AbstractPollingIoProcessor.java:715)
        at org.apache.mina.core.polling.AbstractPollingIoProcessor.process(AbstractPollingIoProcessor.java:668)
        at org.apache.mina.core.polling.AbstractPollingIoProcessor.process(AbstractPollingIoProcessor.java:657)
        at org.apache.mina.core.polling.AbstractPollingIoProcessor.access$600(AbstractPollingIoProcessor.java:68)
        at org.apache.mina.core.polling.AbstractPollingIoProcessor$Processor.run(AbstractPollingIoProcessor.java:1141)
        at org.apache.mina.util.NamePreservingRunnable.run(NamePreservingRunnable.java:64)
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1110)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:603)
        at java.lang.Thread.run(Thread.java:722)
Caused by: java.io.IOException: Expecting 0x9 but got 0x6a
        at com.googlecode.jcimd.PacketSerializer.readToBufferUntil(PacketSerializer.java:352)
        at com.googlecode.jcimd.PacketSerializer.deserializeFromByteArray(PacketSerializer.java:302)
        at com.googlecode.jcimd.PacketSerializer.deserialize(PacketSerializer.java:276)
        at com.ixonos.cimd.simulator.CIMDPacketDecoder.doDecode(CIMDPacketDecoder.java:56)
        at org.apache.mina.filter.codec.CumulativeProtocolDecoder.decode(CumulativeProtocolDecoder.java:178)
        at org.apache.mina.filter.codec.ProtocolCodecFilter.messageReceived(ProtocolCodecFilter.java:241)
        ... 19 more
marko-asplund commented 12 years ago

fixed