Only create ConnectTimeoutException if really needed (#10596)

Motivation:

Creating exceptions is expensive so we should only do so if really needed. This is basically a port of #10595 for io_uring.

Modifications:

Only create the ConnectTimeoutException if we really need it.

Result:

Less overhead
This commit is contained in:
Norman Maurer 2020-09-22 08:58:14 +02:00 committed by GitHub
parent 0751becf03
commit 8ca81a2563
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -674,9 +674,9 @@ abstract class AbstractIOUringChannel extends AbstractChannel implements UnixCha
@Override
public void run() {
ChannelPromise connectPromise = AbstractIOUringChannel.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());
}
}