Fixed a problem where a channel is closed when a user tries to write a message when a connection attempt is in progress

This commit is contained in:
Trustin Lee 2009-02-09 09:11:09 +00:00
parent f7cc2c971d
commit e757135583

View File

@ -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;
}
}