StreamCorruptedException when using CompatibleObjectDecoder/CompatibleObjectEncoder

Trustin Lee tlee at redhat.com
Mon Mar 16 03:31:57 EDT 2009


I analyzed the problem and concluded that CompatibleObjectDecoder has
an incurable bug.  ObjectInputStream internally uses PeekInputStream
and some buffers to store its state.  With a certain combination of
input sequences, the state of the PeekInputStream or the internal
buffer is not cleared on replay, and therefore subsequent decoding
attempts can fail.  What makes this worse is that ObjectInputStream
doesn't allow me to clear the internal state explicitly, and that's
why this bug is incurable.  The only solution I can think of is to
re-implement ObjectInputStream from scratch, which is not likely to
happen in the near future.

Therefore, the only workaround available at this moment is to switch
from CompatibleObjectEncoder, CompatibleObjectDecoder,
ObjectImputStream, and ObjectOutputStream to ObjectEncoder,
ObjectDecoder, ObjectDecoderInputStream, and ObjectEncoderOutputStream
respectively.

HTH,

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



On Mon, Mar 16, 2009 at 3:15 PM, IanGuedes <iangm at ig.com.br> wrote:
>
> Hi Trustin,
>
> I think the problem has something to do with a mistaken read of header /
> body part of the serialized object. I haven't tested the ObjectDecoder, so I
> don't know if the same problem of the CompatibleObjectDecoder also happens
> with it.
>
> Please let us know when you find out what was the real cause, and the
> "official" solution :-)
>
>
> Best regards,
> Ian
>
>
>
> Trustin Lee-2 wrote:
>>
>> 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/
>>>
>>
>
> --
> View this message in context: http://n2.nabble.com/StreamCorruptedException-when-using-CompatibleObjectDecoder-CompatibleObjectEncoder-tp2468712p2484300.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