StreamCorruptedException when using CompatibleObjectDecoder/CompatibleObjectEncoder

IanGuedes iangm at ig.com.br
Mon Mar 16 00:18:01 EDT 2009


Hi,
I've solved the problem reimplementing CompatibleObjectDecoder. The code now
is:


public class SimpleObjectDecoder extends ReplayingDecoder<VoidEnum> {

	@Override
	protected Object decode(ChannelHandlerContext ctx, Channel channel,
			ChannelBuffer buffer, VoidEnum state) throws Exception {

		ChannelBufferInputStream in = new ChannelBufferInputStream(buffer);
		ObjectInputStream oin = new ObjectInputStream(in);
		return oin.readObject();
	}
}

And it works fine :-)


IanGuedes wrote:
> 
> Hi all,
> 
> first of all, I would like to congratulate Trustin Lee for the great job
> on Netty. The API is really well designed (and implemented) and the
> project is very well documented.
> 
> I'm using Netty as a server which receives java object messages requests.
> These requests are made using regular sockets, without Netty. I'm
> experiencing exceptions like:
> java.lang.ClassCastException: java.io.ObjectStreamClass cannot be cast to
> java.lang.String 
> java.io.OptionalDataException
> java.io.StreamCorruptedException: unexpected end of block data
> 
> All are thrown by CompatibleObjectDecoder.java:89, by decode method. These
> happen after a first connection is succefully sent and closed by the
> remote client and received by the server; when he tries to send a second
> message (using another connection), the above exception happens before the
> handler's messageReceived() method is called. Then the exceptionCaught()
> handler's method is called, and when I try to close the connection, the
> StreamCorruptedException or OptionalDataException happens.
> 
> I've tried to to add the encoder/decoder using the ChannelPipelineFactory
> and on the channelOpen, but the same errors happen.
> 
> 
> Does anyone has experienced the same problem?
> 
> Thanks in advance,
> Ian
> 
> 

-- 
View this message in context: http://n2.nabble.com/StreamCorruptedException-when-using-CompatibleObjectDecoder-CompatibleObjectEncoder-tp2468712p2484080.html
Sent from the Netty User Group mailing list archive at Nabble.com.




More information about the netty-users mailing list