[#1036] Use SocketTimeoutException when a connection timeout is detected to make it easier to detect timeout vs refused

This commit is contained in:
Norman Maurer 2013-02-27 10:19:26 +01:00
parent dc4c4ab6b9
commit cb202da832
2 changed files with 6 additions and 4 deletions

View File

@ -22,6 +22,7 @@ import io.netty.channel.EventLoop;
import java.net.ConnectException;
import java.net.SocketAddress;
import java.net.SocketTimeoutException;
import java.nio.channels.AsynchronousChannel;
import java.util.concurrent.ScheduledFuture;
import java.util.concurrent.TimeUnit;
@ -114,8 +115,8 @@ public abstract class AbstractAioChannel extends AbstractChannel {
@Override
public void run() {
ChannelPromise connectFuture = connectPromise;
ConnectException cause =
new ConnectException("connection timed out: " + remoteAddress);
SocketTimeoutException cause =
new SocketTimeoutException("connection timed out: " + remoteAddress);
if (connectFuture != null && connectFuture.tryFailure(cause)) {
close(voidFuture());
}

View File

@ -26,6 +26,7 @@ import io.netty.util.internal.logging.InternalLoggerFactory;
import java.io.IOException;
import java.net.ConnectException;
import java.net.SocketAddress;
import java.net.SocketTimeoutException;
import java.nio.channels.CancelledKeyException;
import java.nio.channels.SelectableChannel;
import java.nio.channels.SelectionKey;
@ -183,8 +184,8 @@ public abstract class AbstractNioChannel extends AbstractChannel {
@Override
public void run() {
ChannelPromise connectPromise = AbstractNioChannel.this.connectPromise;
ConnectException cause =
new ConnectException("connection timed out: " + remoteAddress);
SocketTimeoutException cause =
new SocketTimeoutException("connection timed out: " + remoteAddress);
if (connectPromise != null && connectPromise.tryFailure(cause)) {
close(voidFuture());
}