From e7571355834f68275bbf0b5dcc3f5eab6dde1642 Mon Sep 17 00:00:00 2001 From: Trustin Lee Date: Mon, 9 Feb 2009 09:11:09 +0000 Subject: [PATCH] Fixed a problem where a channel is closed when a user tries to write a message when a connection attempt is in progress --- .../java/org/jboss/netty/bootstrap/ClientBootstrap.java | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/main/java/org/jboss/netty/bootstrap/ClientBootstrap.java b/src/main/java/org/jboss/netty/bootstrap/ClientBootstrap.java index 19a43f3077..41f67305b3 100644 --- a/src/main/java/org/jboss/netty/bootstrap/ClientBootstrap.java +++ b/src/main/java/org/jboss/netty/bootstrap/ClientBootstrap.java @@ -26,6 +26,7 @@ import static org.jboss.netty.channel.Channels.*; import java.net.InetSocketAddress; import java.net.SocketAddress; +import java.nio.channels.NotYetConnectedException; import java.util.concurrent.BlockingQueue; import java.util.concurrent.LinkedBlockingQueue; import java.util.concurrent.TimeUnit; @@ -289,9 +290,11 @@ public class ClientBootstrap extends Bootstrap { ChannelHandlerContext ctx, ExceptionEvent e) throws Exception { ctx.sendUpstream(e); - if (!finished) { + + Throwable cause = e.getCause(); + if (!(cause instanceof NotYetConnectedException) && !finished) { e.getChannel().close(); - futureQueue.offer(failedFuture(e.getChannel(), e.getCause())); + futureQueue.offer(failedFuture(e.getChannel(), cause)); finished = true; } }