mina-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Ashish <paliwalash...@gmail.com>
Subject Re: Byte Buffer release and acquire doubts
Date Thu, 06 Nov 2008 15:22:39 GMT
Nope you don't need to call release twice to free it.

>From basic analysis there seems to be a minor bug (may be) in the implementation

Essentially, the release() function checks for refCount (Line 447) and
checks for less than equal to 0. If the condition is true
it throws an IllegalStateException. The default refCount is 1, so once
you call acquire(), it becomes 2, first release makes it 1, now call
second release(), condition at line 447 becomes false, so illegal
state exception is not thrown as value of refCount is 1 :-),
after that, refCount-- (Line 453) make it 0. So next time you call
acquire(), it checks again for the refCount as if (refCount <= 0), and
which come to be true, and exception is thrown :-)

MINA Experts can comment more on my interpretation.

In Sumary,

you have to call release() as many times as you called acquire()

Happy Coding :-)

On Thu, Nov 6, 2008 at 11:54 AM, Rajeshwari M <rajim17@gmail.com> wrote:
> Hi All,
>          I've written small program to test bytebuffer acquire and release

> }
> Does that means, we need to call release() two times to release the buffer
> actually ???


Blog: http://www.ashishpaliwal.com/blog

My Photo Galleries: http://www.pbase.com/ashishpaliwal

View raw message