ClosedChannelException thrown when stopping Channel
"이희승 (Trustin Lee)"
trustin at gmail.com
Wed Jul 8 08:27:58 EDT 2009
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)
>
>
More information about the netty-users
mailing list