From 8ca81a2563fbd0c04683132d8c8dbc8fe4741c98 Mon Sep 17 00:00:00 2001 From: Norman Maurer Date: Tue, 22 Sep 2020 08:58:14 +0200 Subject: [PATCH] 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 --- .../java/io/netty/channel/uring/AbstractIOUringChannel.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/transport-native-io_uring/src/main/java/io/netty/channel/uring/AbstractIOUringChannel.java b/transport-native-io_uring/src/main/java/io/netty/channel/uring/AbstractIOUringChannel.java index 8394b10946..d9ac209f96 100644 --- a/transport-native-io_uring/src/main/java/io/netty/channel/uring/AbstractIOUringChannel.java +++ b/transport-native-io_uring/src/main/java/io/netty/channel/uring/AbstractIOUringChannel.java @@ -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()); } }