diff --git a/transport/src/main/java/io/netty/channel/pool/FixedChannelPool.java b/transport/src/main/java/io/netty/channel/pool/FixedChannelPool.java index 153c2bc197..ae8340205e 100644 --- a/transport/src/main/java/io/netty/channel/pool/FixedChannelPool.java +++ b/transport/src/main/java/io/netty/channel/pool/FixedChannelPool.java @@ -194,15 +194,7 @@ public class FixedChannelPool extends SimpleChannelPool { @Override public void onTimeout(AcquireTask task) { // Fail the promise as we timed out. - task.promise.setFailure(new TimeoutException( - "Acquire operation took longer then configured maximum time") { - - // Suppress a warning since the method doesn't need synchronization - @Override - public Throwable fillInStackTrace() { // lgtm[java/non-sync-override] - return this; - } - }); + task.promise.setFailure(new AcquireTimeoutException()); } }; break; @@ -514,4 +506,17 @@ public class FixedChannelPool extends SimpleChannelPool { return GlobalEventExecutor.INSTANCE.newSucceededFuture(null); } + + private static final class AcquireTimeoutException extends TimeoutException { + + private AcquireTimeoutException() { + super("Acquire operation took longer then configured maximum time"); + } + + // Suppress a warning since the method doesn't need synchronization + @Override + public Throwable fillInStackTrace() { // lgtm[java/non-sync-override] + return this; + } + } } diff --git a/transport/src/main/java/io/netty/channel/pool/SimpleChannelPool.java b/transport/src/main/java/io/netty/channel/pool/SimpleChannelPool.java index 050de393c6..d7c5dc9afb 100644 --- a/transport/src/main/java/io/netty/channel/pool/SimpleChannelPool.java +++ b/transport/src/main/java/io/netty/channel/pool/SimpleChannelPool.java @@ -350,12 +350,7 @@ public class SimpleChannelPool implements ChannelPool { handler.channelReleased(channel); promise.setSuccess(null); } else { - closeAndFail(channel, new IllegalStateException("ChannelPool full") { - @Override - public Throwable fillInStackTrace() { - return this; - } - }, promise); + closeAndFail(channel, new ChannelPoolFullException(), promise); } } @@ -418,4 +413,17 @@ public class SimpleChannelPool implements ChannelPool { } }); } + + private static final class ChannelPoolFullException extends IllegalStateException { + + private ChannelPoolFullException() { + super("ChannelPool full"); + } + + // Suppress a warning since the method doesn't need synchronization + @Override + public Throwable fillInStackTrace() { // lgtm[java/non-sync-override] + return this; + } + } }