ClosedChannelException thrown when stopping Channel

neilson9 neil at liquidlabs.co.uk
Wed Jul 8 08:31:51 EDT 2009


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
> 
> 

-- 
View this message in context: http://n2.nabble.com/ClosedChannelException-thrown-when-stopping-Channel-tp3225111p3225156.html
Sent from the Netty User Group mailing list archive at Nabble.com.



More information about the netty-users mailing list