Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ChannelException when releasing external resources (Windows, Oracle JDK) #395

Closed
suiryc opened this issue Jun 12, 2012 · 12 comments
Closed
Assignees
Milestone

Comments

@suiryc
Copy link

suiryc commented Jun 12, 2012

On Windows with Oracle JDK, starting with netty 3.4.0 (3.3.1 is fine) I see strange issues in logs, generally along client connection timeouts.
After some testing I could reproduce it with this dummy client:

  • DiscardClientHandler.java
    import org.jboss.netty.channel.ChannelHandlerContext;
    import org.jboss.netty.channel.ExceptionEvent;
    import org.jboss.netty.channel.MessageEvent;
    import org.jboss.netty.channel.SimpleChannelHandler;
    
    

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

public class DiscardClientHandler extends SimpleChannelHandler {

private static Logger LOGGER = LoggerFactory.getLogger(DiscardClientHandler.class);

@Override
public void messageReceived(ChannelHandlerContext ctx, MessageEvent e) {
}

@Override
public void exceptionCaught(ChannelHandlerContext ctx, ExceptionEvent e) {
    LOGGER.error("Caught exception: " + e.getCause().getMessage(), e.getCause());
    e.getChannel().close();
}

}

  • Test.java
    import java.net.InetSocketAddress;
    import java.util.concurrent.Executors;
    
    

import org.jboss.netty.bootstrap.ClientBootstrap;
import org.jboss.netty.channel.Channel;
import org.jboss.netty.channel.ChannelFactory;
import org.jboss.netty.channel.ChannelFuture;
import org.jboss.netty.channel.ChannelPipeline;
import org.jboss.netty.channel.ChannelPipelineFactory;
import org.jboss.netty.channel.Channels;
import org.jboss.netty.channel.socket.nio.NioClientSocketChannelFactory;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

public class Test {

private static Logger LOGGER = LoggerFactory.getLogger(Test.class);

public static void main(String[] args) {
    String host = "1.1.1.1";
    int port = 1234;
    int loop = 0;

    ChannelFactory factory = new NioClientSocketChannelFactory(
        Executors.newCachedThreadPool(),
        Executors.newCachedThreadPool()
    );

    ClientBootstrap bootstrap = new ClientBootstrap(factory);

    bootstrap.setPipelineFactory(new ChannelPipelineFactory() {
        public ChannelPipeline getPipeline() {
            return Channels.pipeline(new DiscardClientHandler());
        }
    });

    bootstrap.setOption("connectTimeoutMillis", new Integer(1000));

    for (loop = 1; loop <= 2; loop++) {
        ChannelFuture future = bootstrap.connect(new InetSocketAddress(host, port));
        future.awaitUninterruptibly();
        if (!future.isSuccess()) {
            LOGGER.error("Failed to connect: " + future.getCause().getMessage(), future.getCause());
        }
        else {
            Channel channel = future.getChannel();
            channel.close();
            channel.getCloseFuture().awaitUninterruptibly();
        }
    }

    factory.releaseExternalResources();
}

}

With netty 3.3.1, I catch (as expected) the connection timeout:

18:35:01.273 [main] ERROR Test - Failed to connect: connection timed out
java.net.ConnectException: connection timed out
    at org.jboss.netty.channel.socket.nio.NioClientSocketPipelineSink$Boss.processConnectTimeout(NioClientSocketPipelineSink.java:387) ~[netty-3.3.1.Final.jar:na]
    at org.jboss.netty.channel.socket.nio.NioClientSocketPipelineSink$Boss.run(NioClientSocketPipelineSink.java:291) ~[netty-3.3.1.Final.jar:na]
    at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(Unknown Source) ~[na:1.6.0_32]
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source) ~[na:1.6.0_32]
    at java.lang.Thread.run(Unknown Source) ~[na:1.6.0_32]
18:35:01.273 [New I/O client boss #1-1] ERROR DiscardClientHandler - Caught exception: connection timed out
java.net.ConnectException: connection timed out
    at org.jboss.netty.channel.socket.nio.NioClientSocketPipelineSink$Boss.processConnectTimeout(NioClientSocketPipelineSink.java:387) ~[netty-3.3.1.Final.jar:na]
    at org.jboss.netty.channel.socket.nio.NioClientSocketPipelineSink$Boss.run(NioClientSocketPipelineSink.java:291) ~[netty-3.3.1.Final.jar:na]
    at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(Unknown Source) [na:1.6.0_32]
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source) [na:1.6.0_32]
    at java.lang.Thread.run(Unknown Source) [na:1.6.0_32]

With netty 3.4.0 (up to current 3.5.0), I also see the following unexpected netty log:

12 juin 2012 18:36:04 org.jboss.netty.channel.DefaultChannelPipeline
ATTENTION: An exception was thrown by an exception handler.
org.jboss.netty.channel.ChannelException: Failed to create a selector.
    at org.jboss.netty.channel.socket.nio.AbstractNioWorker.start(AbstractNioWorker.java:163)
    at org.jboss.netty.channel.socket.nio.AbstractNioWorker.executeInIoThread(AbstractNioWorker.java:315)
    at org.jboss.netty.channel.socket.nio.NioWorker.executeInIoThread(NioWorker.java:35)
    at org.jboss.netty.channel.socket.nio.AbstractNioWorker.executeInIoThread(AbstractNioWorker.java:299)
    at org.jboss.netty.channel.socket.nio.NioWorker.executeInIoThread(NioWorker.java:35)
    at org.jboss.netty.channel.socket.nio.AbstractNioChannelSink.execute(AbstractNioChannelSink.java:34)
    at org.jboss.netty.channel.Channels.fireExceptionCaughtLater(Channels.java:504)
    at org.jboss.netty.channel.AbstractChannelSink.exceptionCaught(AbstractChannelSink.java:47)
    at org.jboss.netty.channel.Channels.close(Channels.java:821)
    at org.jboss.netty.channel.AbstractChannel.close(AbstractChannel.java:195)
    at org.jboss.netty.channel.ChannelFutureListener$2.operationComplete(ChannelFutureListener.java:52)
    at org.jboss.netty.channel.DefaultChannelFuture.notifyListener(DefaultChannelFuture.java:428)
    at org.jboss.netty.channel.DefaultChannelFuture.notifyListeners(DefaultChannelFuture.java:414)
    at org.jboss.netty.channel.DefaultChannelFuture.setFailure(DefaultChannelFuture.java:381)
    at org.jboss.netty.channel.socket.nio.NioClientSocketPipelineSink$Boss.processConnectTimeout(NioClientSocketPipelineSink.java:394)
    at org.jboss.netty.channel.socket.nio.NioClientSocketPipelineSink$Boss.run(NioClientSocketPipelineSink.java:289)
    at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(Unknown Source)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
    at java.lang.Thread.run(Unknown Source)
Caused by: java.io.IOException: Unable to establish loopback connection
    at sun.nio.ch.PipeImpl$Initializer.run(Unknown Source)
    at java.security.AccessController.doPrivileged(Native Method)
    at sun.nio.ch.PipeImpl.(Unknown Source)
    at sun.nio.ch.SelectorProviderImpl.openPipe(Unknown Source)
    at java.nio.channels.Pipe.open(Unknown Source)
    at sun.nio.ch.WindowsSelectorImpl.(Unknown Source)
    at sun.nio.ch.WindowsSelectorProvider.openSelector(Unknown Source)
    at java.nio.channels.Selector.open(Unknown Source)
    at org.jboss.netty.channel.socket.nio.AbstractNioWorker.start(AbstractNioWorker.java:161)
    ... 18 more
Caused by: java.nio.channels.ClosedByInterruptException
    at java.nio.channels.spi.AbstractInterruptibleChannel.end(Unknown Source)
    at sun.nio.ch.SocketChannelImpl.connect(Unknown Source)
    at java.nio.channels.SocketChannel.open(Unknown Source)
    ... 27 more

This happens on Windows (Oracle JDK, 6 or 7), but not on Ubuntu (OpenJDK 6).
Also the log generally only appears after at least two connections attempts, and is triggered by releaseExternalResources on the channel factory.
I don't know if this is a side effect, but when this happen in a more complex netty configuration it seems a thread remains stuck somewhere because the JVM usually does not stop by itself after resource releasing.

Some search on the intermediate error "Unable to establish loopback connection" shows that it could have been related to a firewall issue. But I did not see anything particular in my firewall logs, and disabling it did not change the outcome.
Is this a bug, or is there something wrong with the way I use netty here ?

@trustin
Copy link
Member

trustin commented Jun 24, 2012

I don't think it's your fault but there's a bug in JDK NIO implementation in Windows probably. It is basically saying that it failed to create a new Selector, which should not really happen. Without a selector, Netty can't do any I/O.

@normanmaurer
Copy link
Member

I will close it for now..

@nanocom
Copy link

nanocom commented Aug 31, 2012

+1 for this issue, I get the same stack in my client when I try to connect to my server and without a network connection (cable disconnected). No solution found for this?

@suiryc
Copy link
Author

suiryc commented Aug 31, 2012

No real solution, but a few more observations.

Waiting a bit before releasing the resources usually help preventing triggering the issue.
So, taking into account the stacktrace and the principle of netty, I did some more tests. And I wonder now if there may be some kind of race condition (or maybe a bad ordering in actions taken) between the connection timeout handling and the resource releasing, maybe coupled with a specificity in Oracle JVM implementation on Windows.

Netty 3.5.5.Final stacktrace:

org.jboss.netty.channel.ChannelException: Failed to create a selector.
    at org.jboss.netty.channel.socket.nio.AbstractNioWorker.start(AbstractNioWorker.java:178)
    at org.jboss.netty.channel.socket.nio.AbstractNioWorker.executeInIoThread(AbstractNioWorker.java:330)
    at org.jboss.netty.channel.socket.nio.NioWorker.executeInIoThread(NioWorker.java:35)
    at org.jboss.netty.channel.socket.nio.AbstractNioWorker.executeInIoThread(AbstractNioWorker.java:313)
    at org.jboss.netty.channel.socket.nio.NioWorker.executeInIoThread(NioWorker.java:35)
    at org.jboss.netty.channel.socket.nio.AbstractNioChannelSink.execute(AbstractNioChannelSink.java:34)
    at org.jboss.netty.channel.Channels.fireExceptionCaughtLater(Channels.java:504)
    at org.jboss.netty.channel.AbstractChannelSink.exceptionCaught(AbstractChannelSink.java:47)
    at org.jboss.netty.channel.Channels.close(Channels.java:820)
    at org.jboss.netty.channel.AbstractChannel.close(AbstractChannel.java:195)
    at org.jboss.netty.channel.ChannelFutureListener$2.operationComplete(ChannelFutureListener.java:52)
    at org.jboss.netty.channel.DefaultChannelFuture.notifyListener(DefaultChannelFuture.java:428)
    at org.jboss.netty.channel.DefaultChannelFuture.notifyListeners(DefaultChannelFuture.java:414)
    at org.jboss.netty.channel.DefaultChannelFuture.setFailure(DefaultChannelFuture.java:381)
    at org.jboss.netty.channel.socket.nio.NioClientSocketPipelineSink$Boss.processConnectTimeout(NioClientSocketPipelineSink.java:394)
    at org.jboss.netty.channel.socket.nio.NioClientSocketPipelineSink$Boss.run(NioClientSocketPipelineSink.java:289)
    at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
    at java.lang.Thread.run(Thread.java:662)
Caused by: java.io.IOException: Unable to establish loopback connection
    at sun.nio.ch.PipeImpl$Initializer.run(PipeImpl.java:106)
    at java.security.AccessController.doPrivileged(Native Method)
    at sun.nio.ch.PipeImpl.<init>(PipeImpl.java:122)
    at sun.nio.ch.SelectorProviderImpl.openPipe(SelectorProviderImpl.java:27)
    at java.nio.channels.Pipe.open(Pipe.java:133)
    at sun.nio.ch.WindowsSelectorImpl.<init>(WindowsSelectorImpl.java:104)
    at sun.nio.ch.WindowsSelectorProvider.openSelector(WindowsSelectorProvider.java:26)
    at java.nio.channels.Selector.open(Selector.java:209)
    at org.jboss.netty.channel.socket.nio.AbstractNioWorker.start(AbstractNioWorker.java:176)
    ... 18 more
Caused by: java.nio.channels.ClosedByInterruptException
    at java.nio.channels.spi.AbstractInterruptibleChannel.end(AbstractInterruptibleChannel.java:184)
    at sun.nio.ch.SocketChannelImpl.connect(SocketChannelImpl.java:543)
    at java.nio.channels.SocketChannel.open(SocketChannel.java:146)
    at sun.nio.ch.PipeImpl$Initializer.run(PipeImpl.java:78)
    ... 26 more
java.lang.Exception
    at Test$1.operationComplete(Test.java:56)
    at org.jboss.netty.channel.DefaultChannelFuture.notifyListener(DefaultChannelFuture.java:428)
    at org.jboss.netty.channel.DefaultChannelFuture.notifyListeners(DefaultChannelFuture.java:419)
    at org.jboss.netty.channel.DefaultChannelFuture.setFailure(DefaultChannelFuture.java:381)
    at org.jboss.netty.channel.socket.nio.NioClientSocketPipelineSink$Boss.processConnectTimeout(NioClientSocketPipelineSink.java:394)
    at org.jboss.netty.channel.socket.nio.NioClientSocketPipelineSink$Boss.run(NioClientSocketPipelineSink.java:289)
    at org.jboss.netty.util.ThreadRenamingRunnable.run(ThreadRenamingRunnable.java:102)
    at org.jboss.netty.util.internal.DeadLockProofWorker$1.run(DeadLockProofWorker.java:42)
    at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
    at java.lang.Thread.run(Thread.java:662)

As one can see in the stacktrace, at some point the timeout handling triggers the issue notification to listeners. That's when the ChannelFuture obtained from the ClientBootstrap completes: for example attaching a listener to it and printing the current stacktrace gives

java.lang.Exception
    at Test$1.operationComplete(Test.java:56)
    at org.jboss.netty.channel.DefaultChannelFuture.notifyListener(DefaultChannelFuture.java:428)
    at org.jboss.netty.channel.DefaultChannelFuture.notifyListeners(DefaultChannelFuture.java:419)
    at org.jboss.netty.channel.DefaultChannelFuture.setFailure(DefaultChannelFuture.java:381)
    at org.jboss.netty.channel.socket.nio.NioClientSocketPipelineSink$Boss.processConnectTimeout(NioClientSocketPipelineSink.java:394)
    at org.jboss.netty.channel.socket.nio.NioClientSocketPipelineSink$Boss.run(NioClientSocketPipelineSink.java:289)
    at org.jboss.netty.util.ThreadRenamingRunnable.run(ThreadRenamingRunnable.java:102)
    at org.jboss.netty.util.internal.DeadLockProofWorker$1.run(DeadLockProofWorker.java:42)
    at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
    at java.lang.Thread.run(Thread.java:662)

So since the future is completed my code just goes on to release the ChannelFactory resources before leaving.
But it seems (see the original netty stacktrace) there is a listener that was also automatically attached: org.jboss.netty.channel.ChannelFutureListener.CLOSE_ON_FAILURE
And it appears this listener is somehow notified (ordering of listeners ?) or executed (race condition ?) after my client is notified of the connection failure. And at some point this listener sends the exception upstream in the channel pipeline (actually this is how I receive and log in DiscardClientHandler.exceptionCaught) ... while my code is releasing the resources.

So now maybe there is a specificity due to the Oracle JVM implementation on windows, but when releasing the ChannelFactory resources, a signal interrupts what may be happening inside the channel pipeline. For example if I add a Thread.sleep() long enough - with catching and trashing any throwable - in DiscardClientHandler.exceptionCaught, I get the following interrupt, and does not get the issue deep inside netty:

java.lang.InterruptedException: sleep interrupted
    at java.lang.Thread.sleep(Native Method)
    at DiscardClientHandler.exceptionCaught(DiscardClientHandler.java:20)
    at org.jboss.netty.channel.SimpleChannelHandler.handleUpstream(SimpleChannelHandler.java:137)
    at org.jboss.netty.channel.DefaultChannelPipeline.sendUpstream(DefaultChannelPipeline.java:565)
    at org.jboss.netty.channel.DefaultChannelPipeline$DefaultChannelHandlerContext.sendUpstream(DefaultChannelPipeline.java:793)
    at org.jboss.netty.channel.SimpleChannelUpstreamHandler.exceptionCaught(SimpleChannelUpstreamHandler.java:143)
    at org.jboss.netty.channel.SimpleChannelUpstreamHandler.handleUpstream(SimpleChannelUpstreamHandler.java:117)
    at org.jboss.netty.channel.DefaultChannelPipeline.sendUpstream(DefaultChannelPipeline.java:565)
    at org.jboss.netty.channel.DefaultChannelPipeline.sendUpstream(DefaultChannelPipeline.java:560)
    at org.jboss.netty.channel.Channels.fireExceptionCaught(Channels.java:533)
    at org.jboss.netty.channel.socket.nio.NioClientSocketPipelineSink$Boss.processConnectTimeout(NioClientSocketPipelineSink.java:395)
    at org.jboss.netty.channel.socket.nio.NioClientSocketPipelineSink$Boss.run(NioClientSocketPipelineSink.java:289)
    at org.jboss.netty.util.ThreadRenamingRunnable.run(ThreadRenamingRunnable.java:102)
    at org.jboss.netty.util.internal.DeadLockProofWorker$1.run(DeadLockProofWorker.java:42)
    at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
    at java.lang.Thread.run(Thread.java:662)

So, is there a way in netty to wait for any pending action inside the channel pipeline (before releasing the resources) ?
Or actually, is the channel pipeline expected to still work (and not get interrupts) while/after releasing the ChannelFactory resources ?

@suiryc
Copy link
Author

suiryc commented Aug 31, 2012

Tested with OpenJDK 6 under Ubuntu: waiting inside DiscardClientHandler.exceptionCaught also get the interrupt when resources are released.

So it would look like the netty stacktrace under Windows is a side effect (Oracle implementation that does something that can be interrupted, unlike OpenJDK ?), and that the real issue is that the connection timeout actions can take place while the application has already been notified of the connection failure: hence a possible race condition with resource cleanup.

@ghost ghost assigned normanmaurer Sep 3, 2012
normanmaurer added a commit that referenced this issue Sep 3, 2012
@normanmaurer normanmaurer reopened this Sep 3, 2012
@normanmaurer
Copy link
Member

@suiryc @nanocom could both of you test latest netty 3.5.7.Final-SNAPSHOT. I think I fixed it.

http://repository-netty.forge.cloudbees.com/snapshot/

@suiryc
Copy link
Author

suiryc commented Sep 3, 2012

Not quite yet it seems:

3 sept. 2012 20:23:27 org.jboss.netty.channel.DefaultChannelPipeline
ATTENTION: An exception was thrown by an exception handler.
org.jboss.netty.channel.ChannelException: Failed to create a selector.
    at org.jboss.netty.channel.socket.nio.AbstractNioWorker.start(AbstractNioWorker.java:222)
    at org.jboss.netty.channel.socket.nio.AbstractNioWorker.executeInIoThread(AbstractNioWorker.java:445)
    at org.jboss.netty.channel.socket.nio.NioWorker.executeInIoThread(NioWorker.java:35)
    at org.jboss.netty.channel.socket.nio.AbstractNioWorker.executeInIoThread(AbstractNioWorker.java:414)
    at org.jboss.netty.channel.socket.nio.NioWorker.executeInIoThread(NioWorker.java:35)
    at org.jboss.netty.channel.socket.nio.AbstractNioChannelSink.execute(AbstractNioChannelSink.java:34)
    at org.jboss.netty.channel.Channels.fireExceptionCaughtLater(Channels.java:504)
    at org.jboss.netty.channel.AbstractChannelSink.exceptionCaught(AbstractChannelSink.java:47)
    at org.jboss.netty.channel.Channels.close(Channels.java:820)
    at org.jboss.netty.channel.AbstractChannel.close(AbstractChannel.java:197)
    at org.jboss.netty.channel.ChannelFutureListener$2.operationComplete(ChannelFutureListener.java:52)
    at org.jboss.netty.channel.DefaultChannelFuture.notifyListener(DefaultChannelFuture.java:428)
    at org.jboss.netty.channel.DefaultChannelFuture.notifyListeners(DefaultChannelFuture.java:414)
    at org.jboss.netty.channel.DefaultChannelFuture.setFailure(DefaultChannelFuture.java:381)
    at org.jboss.netty.channel.socket.nio.NioClientSocketPipelineSink$Boss.processConnectTimeout(NioClientSocketPipelineSink.java:457)
    at org.jboss.netty.channel.socket.nio.NioClientSocketPipelineSink$Boss.run(NioClientSocketPipelineSink.java:344)
    at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
    at java.lang.Thread.run(Thread.java:662)
Caused by: java.io.IOException: Unable to establish loopback connection
    at sun.nio.ch.PipeImpl$Initializer.run(PipeImpl.java:106)
    at java.security.AccessController.doPrivileged(Native Method)
    at sun.nio.ch.PipeImpl.<init>(PipeImpl.java:122)
    at sun.nio.ch.SelectorProviderImpl.openPipe(SelectorProviderImpl.java:27)
    at java.nio.channels.Pipe.open(Pipe.java:133)
    at sun.nio.ch.WindowsSelectorImpl.<init>(WindowsSelectorImpl.java:104)
    at sun.nio.ch.WindowsSelectorProvider.openSelector(WindowsSelectorProvider.java:26)
    at java.nio.channels.Selector.open(Selector.java:209)
    at org.jboss.netty.channel.socket.nio.AbstractNioWorker.start(AbstractNioWorker.java:220)
    ... 18 more
Caused by: java.nio.channels.ClosedByInterruptException
    at java.nio.channels.spi.AbstractInterruptibleChannel.end(AbstractInterruptibleChannel.java:184)
    at sun.nio.ch.SocketChannelImpl.connect(SocketChannelImpl.java:543)
    at java.nio.channels.SocketChannel.open(SocketChannel.java:146)
    at sun.nio.ch.PipeImpl$Initializer.run(PipeImpl.java:78)
    ... 26 more
20:23:27.294 [New I/O client boss #1-0] ERROR DiscardClientHandler - Caught exception: connection timed out
java.net.ConnectException: connection timed out
    at org.jboss.netty.channel.socket.nio.NioClientSocketPipelineSink$Boss.processConnectTimeout(NioClientSocketPipelineSink.java:454) ~[netty-3.5.7.Final-SNAPSHOT.jar:na]
    at org.jboss.netty.channel.socket.nio.NioClientSocketPipelineSink$Boss.run(NioClientSocketPipelineSink.java:344) ~[netty-3.5.7.Final-SNAPSHOT.jar:na]
    at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886) [na:1.6.0_35]
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908) [na:1.6.0_35]
    at java.lang.Thread.run(Thread.java:662) [na:1.6.0_35]

From the source code lines in the staktrace, it looks like at the time of execution the isShutdown variable you added was not yet true.

@normanmaurer
Copy link
Member

@suiryc thanks for testing.. could you please grab the latest snapshot again and test ?

@suiryc
Copy link
Author

suiryc commented Sep 3, 2012

Thanks for the fixes. The latest snapshot do not trigger the selector creation issue anymore.

There is still an interrupt for code that may be waiting and the like in exceptionCaught callbacks, but maybe that's the intended behaviour ?

java.lang.InterruptedException: sleep interrupted
    at java.lang.Thread.sleep(Native Method)
    at DiscardClientHandler.exceptionCaught(DiscardClientHandler.java:20)
    at org.jboss.netty.channel.SimpleChannelHandler.handleUpstream(SimpleChannelHandler.java:137)
    at org.jboss.netty.channel.DefaultChannelPipeline.sendUpstream(DefaultChannelPipeline.java:565)
    at org.jboss.netty.channel.DefaultChannelPipeline$DefaultChannelHandlerContext.sendUpstream(DefaultChannelPipeline.java:793)
    at org.jboss.netty.channel.SimpleChannelUpstreamHandler.exceptionCaught(SimpleChannelUpstreamHandler.java:143)
    at org.jboss.netty.channel.SimpleChannelUpstreamHandler.handleUpstream(SimpleChannelUpstreamHandler.java:117)
    at org.jboss.netty.channel.DefaultChannelPipeline.sendUpstream(DefaultChannelPipeline.java:565)
    at org.jboss.netty.channel.DefaultChannelPipeline.sendUpstream(DefaultChannelPipeline.java:560)
    at org.jboss.netty.channel.Channels.fireExceptionCaught(Channels.java:533)
    at org.jboss.netty.channel.socket.nio.NioClientSocketPipelineSink$Boss.processConnectTimeout(NioClientSocketPipelineSink.java:458)
    at org.jboss.netty.channel.socket.nio.NioClientSocketPipelineSink$Boss.run(NioClientSocketPipelineSink.java:344)
    at org.jboss.netty.util.ThreadRenamingRunnable.run(ThreadRenamingRunnable.java:102)
    at org.jboss.netty.util.internal.DeadLockProofWorker$1.run(DeadLockProofWorker.java:42)
    at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
    at java.lang.Thread.run(Thread.java:662)
21:30:55.129 [New I/O client boss #1-0] ERROR DiscardClientHandler - Caught exception: connection timed out
java.net.ConnectException: connection timed out
    at org.jboss.netty.channel.socket.nio.NioClientSocketPipelineSink$Boss.processConnectTimeout(NioClientSocketPipelineSink.java:454) ~[netty-3.5.7.Final-SNAPSHOT.jar:na]
    at org.jboss.netty.channel.socket.nio.NioClientSocketPipelineSink$Boss.run(NioClientSocketPipelineSink.java:344) ~[netty-3.5.7.Final-SNAPSHOT.jar:na]
    at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886) [na:1.6.0_35]
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908) [na:1.6.0_35]
    at java.lang.Thread.run(Thread.java:662) [na:1.6.0_35]

Anyway I guess having such kind of code may not be what people should do in such a place (exception handling), so maybe someone will have to open a new ticket if he believes this behaviour should be changed.

@normanmaurer
Copy link
Member

@suiryc thanks for the confirm. So we can finally close this and have the fix included. YAY!

@suiryc suiryc closed this as completed Sep 3, 2012
@normanmaurer
Copy link
Member

There is one issue left now.. We need to handle the case when a Channel will be registered on an AbstractNioWorker which was shutdown.
I will take care of this tomorrow morning..

Sent from my iPhone. Excuse any typos....

Am 03.09.2012 um 21:43 schrieb Julien Coloos notifications@github.com:

Thanks for the fixes. The latest snapshot do not trigger the selector creation issue anymore.

There is still an interrupt for code that may be waiting and the like in exceptionCaught callbacks, but maybe that's the intended behaviour ?

java.lang.InterruptedException: sleep interrupted
at java.lang.Thread.sleep(Native Method)
at DiscardClientHandler.exceptionCaught(DiscardClientHandler.java:20)
at org.jboss.netty.channel.SimpleChannelHandler.handleUpstream(SimpleChannelHandler.java:137)
at org.jboss.netty.channel.DefaultChannelPipeline.sendUpstream(DefaultChannelPipeline.java:565)
at org.jboss.netty.channel.DefaultChannelPipeline$DefaultChannelHandlerContext.sendUpstream(DefaultChannelPipeline.java:793)
at org.jboss.netty.channel.SimpleChannelUpstreamHandler.exceptionCaught(SimpleChannelUpstreamHandler.java:143)
at org.jboss.netty.channel.SimpleChannelUpstreamHandler.handleUpstream(SimpleChannelUpstreamHandler.java:117)
at org.jboss.netty.channel.DefaultChannelPipeline.sendUpstream(DefaultChannelPipeline.java:565)
at org.jboss.netty.channel.DefaultChannelPipeline.sendUpstream(DefaultChannelPipeline.java:560)
at org.jboss.netty.channel.Channels.fireExceptionCaught(Channels.java:533)
at org.jboss.netty.channel.socket.nio.NioClientSocketPipelineSink$Boss.processConnectTimeout(NioClientSocketPipelineSink.java:458)
at org.jboss.netty.channel.socket.nio.NioClientSocketPipelineSink$Boss.run(NioClientSocketPipelineSink.java:344)
at org.jboss.netty.util.ThreadRenamingRunnable.run(ThreadRenamingRunnable.java:102)
at org.jboss.netty.util.internal.DeadLockProofWorker$1.run(DeadLockProofWorker.java:42)
at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
at java.lang.Thread.run(Thread.java:662)
21:30:55.129 [New I/O client boss #1-0] ERROR DiscardClientHandler - Caught exception: connection timed out
java.net.ConnectException: connection timed out
at org.jboss.netty.channel.socket.nio.NioClientSocketPipelineSink$Boss.processConnectTimeout(NioClientSocketPipelineSink.java:454) ~[netty-3.5.7.Final-SNAPSHOT.jar:na]
at org.jboss.netty.channel.socket.nio.NioClientSocketPipelineSink$Boss.run(NioClientSocketPipelineSink.java:344) ~[netty-3.5.7.Final-SNAPSHOT.jar:na]
at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886) [na:1.6.0_35]
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908) [na:1.6.0_35]
at java.lang.Thread.run(Thread.java:662) [na:1.6.0_35]
Anyway I guess having such kind of code may not be what people should do in such a place (exception handling), so maybe someone will have to open a new ticket if he believes this behaviour should be changed.


Reply to this email directly or view it on GitHub.

@nanocom
Copy link

nanocom commented Sep 4, 2012

I had managed to avoid the stack (don't ask me how) but thanks @normanmaurer

@normanmaurer normanmaurer mentioned this issue Apr 1, 2013
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants