ClosedChannelException thrown when stopping Channel
"이희승 (Trustin Lee)"
trustin at gmail.com
Thu Jul 9 02:32:26 EDT 2009
I modified Netty NIO transport implementation to raise
ClosedChannelException only once even if there were many pending write
requests, because I couldn't think of any negative side effect but
speedup in connection cleanup. Let me know if this change breaks your
application.
Thanks for a good idea,
Trustin
On 07/08/2009 09:31 PM, neilson9 wrote:
> Sorry - I realised my mistake after the post - throwing an exception makes
> sense when a write event is pending...
> Regards Neil.
>
>
> Trustin Lee wrote:
>> If a channel has been closed and there are pending writes which were not
>> written yet, ClosedChannelException is raised for each write request.
>> You can simply discard the exception if it was intentional.
>>
>> One idea though is it might be a better idea to fire exceptionCaught
>> event only once while notifying all futures. I'm still not sure about
>> the negative side effect of this change. WDYT?
>>
>> Thanks,
>> Trustin
>>
>> On 07/08/2009 09:21 PM, neilson9 wrote:
>>> Hi,
>>> In my connection pool Im invalidating and closing connections when they
>>> are
>>> no longer needed (i.e. pools hightwater mark is reached) and I seem to
>>> get
>>> many ClosedChannelExceptions. Looking at the Stack and the Source Code
>>> [below] it looks like I will either get a NotYetConnectedException OR a
>>> ClosedChannelException - when stopping a channel.
>>>
>>> Is it possible to prevent this from happening?
>>> Regards Neil.
>>>
>>> >From NioWorker.cleanUpWriteBuffer
>>> // Create the exception only once to avoid the excessive
>>> overhead
>>> // caused by fillStackTrace.
>>> if (channel.isOpen()) {
>>> cause = new NotYetConnectedException();
>>> } else {
>>> cause = new ClosedChannelException();
>>> }
>>> evt.getFuture().setFailure(cause);
>>>
>>> fireExceptionCaught(channel, cause);
>>>
>>> The exception picked up by my Handler
>>> 2009-07-08 13:10:16,272 WARN 3:10000-10-10 (netty.NettyClientHandler)
>>> com.liquidlabs.transport.netty.NettyClientHandler at 3f84e8 m:null
>>> Client[null]] Unexpected exception from downstream, latch[null]
>>> java.nio.channels.ClosedChannelException
>>> at
>>> org.jboss.netty.channel.socket.nio.NioWorker.cleanUpWriteBuffer(NioWorker.java:609)
>>> at
>>> org.jboss.netty.channel.socket.nio.NioWorker.close(NioWorker.java:568)
>>> at
>>> org.jboss.netty.channel.socket.nio.NioClientSocketPipelineSink.eventSunk(NioClientSocketPipelineSink.java:97)
>>> at org.jboss.netty.channel.Channels.close(Channels.java:1043)
>>> at
>>> org.jboss.netty.channel.AbstractChannel.close(AbstractChannel.java:185)
>>> at com.ll.transport.netty.NettySenderImpl.stop(NettySenderImpl.java:118)
>>>
>>>
>> _______________________________________________
>> 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