[#2713] Always use correct remote address in ConnectTimeoutException
Motivation: As we cached ConnectTimeoutException we sometimes ended up using the wrong remote address in the exception message. Modifications: Always create a new ConnectTimeException and so make sure we use the connect remote address. This has a bit more overhead because of fill in the stacktrace everytime but as this only happens on connection timeouts it should be ok. Result: Always include the correct remote address in ConnectTimeoutException.
This commit is contained in:
parent
611269c0f0
commit
c44be8e468
@ -115,7 +115,6 @@ public final class NioClientBoss extends AbstractNioSelector implements Boss {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private static void processConnectTimeout(Set<SelectionKey> keys, long currentTimeNanos) {
|
private static void processConnectTimeout(Set<SelectionKey> keys, long currentTimeNanos) {
|
||||||
ConnectException cause = null;
|
|
||||||
for (SelectionKey k: keys) {
|
for (SelectionKey k: keys) {
|
||||||
if (!k.isValid()) {
|
if (!k.isValid()) {
|
||||||
// Comment the close call again as it gave us major problems
|
// Comment the close call again as it gave us major problems
|
||||||
@ -133,9 +132,12 @@ public final class NioClientBoss extends AbstractNioSelector implements Boss {
|
|||||||
if (ch.connectDeadlineNanos > 0 &&
|
if (ch.connectDeadlineNanos > 0 &&
|
||||||
currentTimeNanos >= ch.connectDeadlineNanos) {
|
currentTimeNanos >= ch.connectDeadlineNanos) {
|
||||||
|
|
||||||
if (cause == null) {
|
// Create a new ConnectException everytime and not cache it as otherwise we end up with
|
||||||
cause = new ConnectTimeoutException("connection timed out: " + ch.requestedRemoteAddress);
|
// using the wrong remoteaddress in the ConnectException message.
|
||||||
}
|
//
|
||||||
|
// See https://github.com/netty/netty/issues/2713
|
||||||
|
ConnectException cause =
|
||||||
|
new ConnectTimeoutException("connection timed out: " + ch.requestedRemoteAddress);
|
||||||
|
|
||||||
ch.connectFuture.setFailure(cause);
|
ch.connectFuture.setFailure(cause);
|
||||||
fireExceptionCaught(ch, cause);
|
fireExceptionCaught(ch, cause);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user