[ https://issues.apache.org/jira/browse/DIRMINA-634?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12701873#action_12701873 ]
Ryan Gow edited comment on DIRMINA-634 at 4/23/09 2:49 AM: ----------------------------------------------------------- Hi, Using the test application provided by Ben (a colleague of mine), I think I've tracked down what appears to be the problem. The issue seems to occur when closing the session. The SocketIoProcessor.releaseWriteBuffers(SocketSessionImpl) method releases the first buffer in the write request queue in a try block but the associated finally (according to the comments) forwards the first unwritten empty buffer to the filter chain. This will eventually result in the same, already released, buffer being released again. Isn't it only necessary to explicitly release the buffer in the SocketIoProcessor.releaseWriteBuffers(SocketSessionImpl) method when the buffer is not going to be forwarded through the filter chain? The filter chain will ensure that the buffer is released once the message is sent by the handler. Moving some of the code around in SocketIoProcessor.releaseWriteBuffers(SocketSessionImpl) to ensure that the unwritten buffer is only released when it is not being forwarded through the filter chain i.e. when it is not empty, seems to resolve the issue. Something like: <pre> try { if (buf.hasRemaining()) { req.getFuture().setWritten(false); buf.release(); } else { session.getFilterChain().fireMessageSent(session, req); } } catch (IllegalStateException e) { session.getFilterChain().fireExceptionCaught(session, e); } </pre> At least, it is no longer reproducable with the test application supplied by Ben. was (Author: rgow): Hi, Using the test application provided by Ben (a colleague of mine), I think I've tracked down what appears to be the problem. The issue seems to occur when closing the session. The SocketIoProcessor.releaseWriteBuffers(SocketSessionImpl) method releases the first buffer in the write request queue in a try block but the associated finally (according to the comments) forwards the first unwritten empty buffer to the filter chain. This will eventually result in the same, already released, buffer being released again. Isn't it only necessary to explicitly release the buffer in the SocketIoProcessor.releaseWriteBuffers(SocketSessionImpl) method when the buffer is not going to be forwarded through the filter chain? The filter chain will ensure that the buffer is released once the message is sent by the handler. Moving some of the code around in SocketIoProcessor.releaseWriteBuffers(SocketSessionImpl) to ensure that the unwritten buffer is only released when it is not being forwarded through the filter chain i.e. when it is not empty, seems to resolve the issue. At least, it is no longer reproducable with the test application supplied by Ben. > IllegalStateException: Already released Buffer in SSLFilter messageSent() > ------------------------------------------------------------------------- > > Key: DIRMINA-634 > URL: https://issues.apache.org/jira/browse/DIRMINA-634 > Project: MINA > Issue Type: Bug > Components: Filter > Affects Versions: 1.1.6 > Environment: Solaris > Reporter: Rajeshwari > Fix For: 1.1.8 > > Attachments: illegalstate_buffer_bug_repro.zip > > > I'm using mina1.1.6 version. I got the following exception.. > E20:02:57.20 ERROR DEFAULT 1 Runtime error: > java.lang.IllegalStateException: Already released buffer. You released the > buffer too many times.\n\tat > org.apache.mina.common.SimpleByteBufferAllocator$SimpleByteBuffer.release(SimpleByteBufferAllocator.java:81)\n\tat > > org.apache.mina.common.ByteBufferProxy.release(ByteBufferProxy.java:69)\n\tat > org.apache.mina.filter.SSLFilter.messageSent(SSLFilter.java:434)\n\tat > org.apache.mina.common.support.AbstractIoFilterChain.callNextMessageSent(AbstractIoFilterChain.java:320)\n\tat > > org.apache.mina.common.support.AbstractIoFilterChain.access$1200(AbstractIoFilterChain.java:53)\n\tat > > org.apache.mina.common.support.AbstractIoFilterChain$EntryImpl$1.messageSent(AbstractIoFilterChain.java:653)\n\tat > > org.apache.mina.common.IoFilterAdapter.messageSent(IoFilterAdapter.java:85)\n\tat > > org.apache.mina.common.support.AbstractIoFilterChain.callNextMessageSent(AbstractIoFilterChain.java:320)\n\tat > > org.apache.mina.common.support.AbstractIoFilterChain.access$1200(AbstractIoFilterChain.java:53)\n\tat > > org.apache.mina.common.support.AbstractIoFilterChain$EntryImpl$1.messageSent(AbstractIoFilterChain.java:653)\n\tat > > org.apache.mina.filter.executor.ExecutorFilter.processEvent(ExecutorFilter.java:222)\n\tat > > org.apache.mina.filter.executor.ExecutorFilter$ProcessEventsRunnable.run(ExecutorFilter.java:264)\n\tat > > java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:650)\n\tat > > java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:675)\n\tat > java.lang.Thread.run(Thread.java:595)\n for reqId = null > E20:02:57.20 WARNING DEFAULT 2 RouteHandler reqId > nulljava.lang.IllegalStateException: Already released buffer. You released > the buffer too many times.\n\tat > org.apache.mina.common.SimpleByteBufferAllocator$SimpleByteBuffer.release(SimpleByteBufferAllocator.java:81)\n\tat > > org.apache.mina.common.ByteBufferProxy.release(ByteBufferProxy.java:69)\n\tat > org.apache.mina.filter.SSLFilter.messageSent(SSLFilter.java:434)\n\tat > org.apache.mina.common.support.AbstractIoFilterChain.callNextMessageSent(AbstractIoFilterChain.java:320)\n\tat > > org.apache.mina.common.support.AbstractIoFilterChain.access$1200(AbstractIoFilterChain.java:53)\n\tat > > org.apache.mina.common.support.AbstractIoFilterChain$EntryImpl$1.messageSent(AbstractIoFilterChain.java:653)\n\tat > > org.apache.mina.common.IoFilterAdapter.messageSent(IoFilterAdapter.java:85)\n\tat > > org.apache.mina.common.support.AbstractIoFilterChain.callNextMessageSent(AbstractIoFilterChain.java:320)\n\tat > > org.apache.mina.common.support.AbstractIoFilterChain.access$1200(AbstractIoFilterChain.java:53)\n\tat > > org.apache.mina.common.support.AbstractIoFilterChain$EntryImpl$1.messageSent(AbstractIoFilterChain.java:653)\n\tat > > org.apache.mina.filter.executor.ExecutorFilter.processEvent(ExecutorFilter.java:222)\n\tat > > org.apache.mina.filter.executor.ExecutorFilter$ProcessEventsRunnable.run(ExecutorFilter.java:264)\n\tat > > java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:650)\n\tat > > java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:675)\n\tat > java.lang.Thread.run(Thread.java:595)\n > Any known bug is there.. ?? > can anyone give insight into this ?? -- This message is automatically generated by JIRA. - You can reply to this email to add a comment to the issue online.