StreamCorruptedException when using CompatibleObjectDecoder/CompatibleObjectEncoder

Trustin Lee tlee at redhat.com
Mon Mar 16 01:22:29 EDT 2009


Doh, nevermind.  I can reproduce the problem now.

— Trustin Lee, http://gleamynode.net/

On Mon, Mar 16, 2009 at 2:09 PM, Trustin Lee <tlee at redhat.com> wrote:
> Hi Ian,
>
> Sorry for not replying to your question mistakenly.  I know you
> already worked around the problem, but would you mind if you provide
> me a simple application that reproduces the problem you experienced?
> I tried to reproduce the problem with object echo example, but
> couldn't.
>
> Thanks,
>
> — Trustin Lee, http://gleamynode.net/
>
> On Mon, Mar 16, 2009 at 1:18 PM, IanGuedes <iangm at ig.com.br> wrote:
>>
>> 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.
>>
>> _______________________________________________
>> netty-users mailing list
>> netty-users at lists.jboss.org
>> https://lists.jboss.org/mailman/listinfo/netty-users
>>
>




More information about the netty-users mailing list