Should close the channel explicitly on connection attempt failure

This commit is contained in:
Trustin Lee 2009-11-16 05:21:51 +00:00
parent f8aea1547e
commit 9c5a14b0c2

View File

@ -142,7 +142,9 @@ class NioClientSocketPipelineSink extends AbstractChannelSink {
channel.getCloseFuture().addListener(new ChannelFutureListener() {
public void operationComplete(ChannelFuture f)
throws Exception {
cf.setFailure(new ClosedChannelException());
if (!cf.isDone()) {
cf.setFailure(new ClosedChannelException());
}
}
});
cf.addListener(ChannelFutureListener.CLOSE_ON_FAILURE);
@ -153,6 +155,7 @@ class NioClientSocketPipelineSink extends AbstractChannelSink {
} catch (Throwable t) {
cf.setFailure(t);
fireExceptionCaught(channel, t);
NioWorker.close(channel, succeededFuture(channel));
}
}