From 2ba00cd358de2f4fbfef12b0be63605d49826f1a Mon Sep 17 00:00:00 2001 From: Trustin Lee Date: Fri, 7 Feb 2014 10:22:04 -0800 Subject: [PATCH] Log the rejected listener notification task under a dedicated logger name. - Fixes #2166 - Some user applications are fine with the failure of notification --- .../netty/util/concurrent/DefaultPromise.java | 48 +++++++++---------- 1 file changed, 23 insertions(+), 25 deletions(-) diff --git a/common/src/main/java/io/netty/util/concurrent/DefaultPromise.java b/common/src/main/java/io/netty/util/concurrent/DefaultPromise.java index ef91bd5a7f..e8fc042eb9 100644 --- a/common/src/main/java/io/netty/util/concurrent/DefaultPromise.java +++ b/common/src/main/java/io/netty/util/concurrent/DefaultPromise.java @@ -31,6 +31,8 @@ import static java.util.concurrent.TimeUnit.*; public class DefaultPromise extends AbstractFuture implements Promise { private static final InternalLogger logger = InternalLoggerFactory.getInstance(DefaultPromise.class); + private static final InternalLogger rejectedExecutionLogger = + InternalLoggerFactory.getInstance(DefaultPromise.class.getName() + ".rejectedExecution"); private static final int MAX_LISTENER_STACK_DEPTH = 8; private static final ThreadLocal LISTENER_STACK_DEPTH = new ThreadLocal() { @@ -574,30 +576,26 @@ public class DefaultPromise extends AbstractFuture implements Promise { } } - try { - if (listeners instanceof DefaultFutureListeners) { - final DefaultFutureListeners dfl = (DefaultFutureListeners) listeners; - execute(executor, new Runnable() { - @Override - public void run() { - notifyListeners0(DefaultPromise.this, dfl); - DefaultPromise.this.listeners = null; - } - }); - } else { - @SuppressWarnings("unchecked") - final GenericFutureListener> l = - (GenericFutureListener>) listeners; - execute(executor, new Runnable() { - @Override - public void run() { - notifyListener0(DefaultPromise.this, l); - DefaultPromise.this.listeners = null; - } - }); - } - } catch (Throwable t) { - logger.error("Failed to notify listener(s). Event loop shut down?", t); + if (listeners instanceof DefaultFutureListeners) { + final DefaultFutureListeners dfl = (DefaultFutureListeners) listeners; + execute(executor, new Runnable() { + @Override + public void run() { + notifyListeners0(DefaultPromise.this, dfl); + DefaultPromise.this.listeners = null; + } + }); + } else { + @SuppressWarnings("unchecked") + final GenericFutureListener> l = + (GenericFutureListener>) listeners; + execute(executor, new Runnable() { + @Override + public void run() { + notifyListener0(DefaultPromise.this, l); + DefaultPromise.this.listeners = null; + } + }); } } @@ -671,7 +669,7 @@ public class DefaultPromise extends AbstractFuture implements Promise { try { executor.execute(task); } catch (Throwable t) { - logger.error("Failed to notify a listener. Event loop shut down?", t); + rejectedExecutionLogger.error("Failed to submit a listener notification task. Event loop shut down?", t); } }