Only create ConnectTimeoutException if really needed (#10595)
Motivation: Creating exceptions is expensive so we should only do so if really needed. Modifications: Only create the ConnectTimeoutException if we really need it. Result: Less overhead
This commit is contained in:
parent
79a7c157a3
commit
71d034593f
@ -31,6 +31,7 @@ import io.netty.channel.ChannelPromise;
|
||||
import io.netty.channel.ConnectTimeoutException;
|
||||
import io.netty.channel.EventLoop;
|
||||
import io.netty.channel.RecvByteBufAllocator;
|
||||
import io.netty.channel.nio.AbstractNioChannel;
|
||||
import io.netty.channel.socket.ChannelInputShutdownEvent;
|
||||
import io.netty.channel.socket.ChannelInputShutdownReadComplete;
|
||||
import io.netty.channel.socket.SocketChannelConfig;
|
||||
@ -572,9 +573,9 @@ abstract class AbstractEpollChannel extends AbstractChannel implements UnixChann
|
||||
@Override
|
||||
public void run() {
|
||||
ChannelPromise connectPromise = AbstractEpollChannel.this.connectPromise;
|
||||
ConnectTimeoutException cause =
|
||||
new ConnectTimeoutException("connection timed out: " + remoteAddress);
|
||||
if (connectPromise != null && connectPromise.tryFailure(cause)) {
|
||||
if (connectPromise != null && !connectPromise.isDone()
|
||||
&& connectPromise.tryFailure(new ConnectTimeoutException(
|
||||
"connection timed out: " + remoteAddress))) {
|
||||
close(voidPromise());
|
||||
}
|
||||
}
|
||||
|
@ -31,6 +31,7 @@ import io.netty.channel.ChannelPromise;
|
||||
import io.netty.channel.ConnectTimeoutException;
|
||||
import io.netty.channel.EventLoop;
|
||||
import io.netty.channel.RecvByteBufAllocator;
|
||||
import io.netty.channel.nio.AbstractNioChannel;
|
||||
import io.netty.channel.socket.ChannelInputShutdownEvent;
|
||||
import io.netty.channel.socket.ChannelInputShutdownReadComplete;
|
||||
import io.netty.channel.socket.SocketChannelConfig;
|
||||
@ -558,9 +559,9 @@ abstract class AbstractKQueueChannel extends AbstractChannel implements UnixChan
|
||||
@Override
|
||||
public void run() {
|
||||
ChannelPromise connectPromise = AbstractKQueueChannel.this.connectPromise;
|
||||
ConnectTimeoutException cause =
|
||||
new ConnectTimeoutException("connection timed out: " + remoteAddress);
|
||||
if (connectPromise != null && connectPromise.tryFailure(cause)) {
|
||||
if (connectPromise != null && !connectPromise.isDone()
|
||||
&& connectPromise.tryFailure(new ConnectTimeoutException(
|
||||
"connection timed out: " + remoteAddress))) {
|
||||
close(voidPromise());
|
||||
}
|
||||
}
|
||||
|
@ -258,9 +258,9 @@ public abstract class AbstractNioChannel extends AbstractChannel {
|
||||
@Override
|
||||
public void run() {
|
||||
ChannelPromise connectPromise = AbstractNioChannel.this.connectPromise;
|
||||
ConnectTimeoutException cause =
|
||||
new ConnectTimeoutException("connection timed out: " + remoteAddress);
|
||||
if (connectPromise != null && connectPromise.tryFailure(cause)) {
|
||||
if (connectPromise != null && !connectPromise.isDone()
|
||||
&& connectPromise.tryFailure(new ConnectTimeoutException(
|
||||
"connection timed out: " + remoteAddress))) {
|
||||
close(voidPromise());
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user