directory-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Trustin Lee <>
Subject Re: Using Mina ByteBuffers
Date Thu, 21 Apr 2005 11:42:47 GMT

2005/4/21, <>:
> Hi,
> I wonder what I have to do to use Mina ByteBuffer implementation in my
> application (in ProtocolDecoder, in order to copy incoming bytes until a
> complete message is received)

You could just use CumulativeProtocolDecoder that does what you want.

> I especially wonder if I must acquire the buffer after calling
> ByteBuffer.allocate (and then release it when work is done), or if
> acquire/release is not needed.
> There is some javadoc about it:
> "Please note that you never need to release the allocated buffer because MINA
> will release it automatically.
> But, if you didn't pass it to MINA or called {@link #acquire()} by yourself, you
> will have to release it manually"
> But I don't understand what is meant by "pass to MINA".

I updated documentation of Acquire/Release section.  Please svn up and
then you'll see more clear explanation.  I'll copy and paste it here:

Please note that you never need to release the allocated buffer
because MINA will release it automatically when:

 * You pass the buffer by calling {@link IoSession#write(ByteBuffer,
 * You pass the buffer by calling {@link

And, you don't need to release any {@link ByteBuffer} which is passed
as a parameter of {@link IoHandler#dataRead(IoSession, ByteBuffer)}
method.  They are released automatically when the method returns.

You have to release buffers manually by calling {@link #release()} when:

 * You allocated a buffer, but didn't pass the buffer to any of two
methods above.</li>
 * You called {@link #acquire()} to prevent the buffer from being released.</li>

Is the documentation clearer now?

what we call human nature is actually human habit

View raw message