You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@mina.apache.org by mat <fo...@gmail.com> on 2007/10/02 10:37:26 UTC

MessageDecoderResult.OK

After MessageDecoderResult.OK in decode(), what mina handle ByteBuffer
in? Remove the remaining byte[] in ByteBuffer to new position? Or ByteBuffer
has special function can do this?

Re: MessageDecoderResult.OK

Posted by mat <fo...@gmail.com>.
No, Trustin. I was asking about actually how Mina handle this internally?
Too lazy to read the source code.^^

On 10/2/07, Trustin Lee <tr...@gmail.com> wrote:
>
> On 10/2/07, mat <fo...@gmail.com> wrote:
> > After MessageDecoderResult.OK in decode(), what mina handle ByteBuffer
> > in? Remove the remaining byte[] in ByteBuffer to new position? Or
> ByteBuffer
> > has special function can do this?
>
> It often retains the reference to the buffer calling compact() and
> flip().  It sometimes replaces the buffer received from the previous
> filter in the chain.  It's because the decoder implementation is
> optimized to minimize memory copy.  So you can't assume about its
> internal behavior.  Please do not try to modify the content of the
> buffer (e.g. calling buffer.compact()); MINA will do that for you.
> Plus, please do not assume that the buffer's position is always 0.  It
> can vary depending on situation.
>
> Trustin
> --
> what we call human nature is actually human habit
> --
> http://gleamynode.net/
> --
> PGP Key ID: 0x0255ECA6
>

Re: MessageDecoderResult.OK

Posted by Trustin Lee <tr...@gmail.com>.
On 10/2/07, mat <fo...@gmail.com> wrote:
> After MessageDecoderResult.OK in decode(), what mina handle ByteBuffer
> in? Remove the remaining byte[] in ByteBuffer to new position? Or ByteBuffer
> has special function can do this?

It often retains the reference to the buffer calling compact() and
flip().  It sometimes replaces the buffer received from the previous
filter in the chain.  It's because the decoder implementation is
optimized to minimize memory copy.  So you can't assume about its
internal behavior.  Please do not try to modify the content of the
buffer (e.g. calling buffer.compact()); MINA will do that for you.
Plus, please do not assume that the buffer's position is always 0.  It
can vary depending on situation.

Trustin
-- 
what we call human nature is actually human habit
--
http://gleamynode.net/
--
PGP Key ID: 0x0255ECA6