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