Log the rejected listener notification task under a dedicated logger name.

- Fixes #2166
- Some user applications are fine with the failure of notification
This commit is contained in:
Trustin Lee 2014-02-07 10:22:04 -08:00
parent 2e064ee87f
commit 78cf0e37e2

View File

@ -31,6 +31,8 @@ import static java.util.concurrent.TimeUnit.*;
public class DefaultPromise<V> extends AbstractFuture<V> implements Promise<V> { public class DefaultPromise<V> extends AbstractFuture<V> implements Promise<V> {
private static final InternalLogger logger = InternalLoggerFactory.getInstance(DefaultPromise.class); 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 int MAX_LISTENER_STACK_DEPTH = 8;
private static final ThreadLocal<Integer> LISTENER_STACK_DEPTH = new ThreadLocal<Integer>() { private static final ThreadLocal<Integer> LISTENER_STACK_DEPTH = new ThreadLocal<Integer>() {
@ -574,30 +576,26 @@ public class DefaultPromise<V> extends AbstractFuture<V> implements Promise<V> {
} }
} }
try { if (listeners instanceof DefaultFutureListeners) {
if (listeners instanceof DefaultFutureListeners) { final DefaultFutureListeners dfl = (DefaultFutureListeners) listeners;
final DefaultFutureListeners dfl = (DefaultFutureListeners) listeners; execute(executor, new Runnable() {
execute(executor, new Runnable() { @Override
@Override public void run() {
public void run() { notifyListeners0(DefaultPromise.this, dfl);
notifyListeners0(DefaultPromise.this, dfl); DefaultPromise.this.listeners = null;
DefaultPromise.this.listeners = null; }
} });
}); } else {
} else { @SuppressWarnings("unchecked")
@SuppressWarnings("unchecked") final GenericFutureListener<? extends Future<V>> l =
final GenericFutureListener<? extends Future<V>> l = (GenericFutureListener<? extends Future<V>>) listeners;
(GenericFutureListener<? extends Future<V>>) listeners; execute(executor, new Runnable() {
execute(executor, new Runnable() { @Override
@Override public void run() {
public void run() { notifyListener0(DefaultPromise.this, l);
notifyListener0(DefaultPromise.this, l); DefaultPromise.this.listeners = null;
DefaultPromise.this.listeners = null; }
} });
});
}
} catch (Throwable t) {
logger.error("Failed to notify listener(s). Event loop shut down?", t);
} }
} }
@ -671,7 +669,7 @@ public class DefaultPromise<V> extends AbstractFuture<V> implements Promise<V> {
try { try {
executor.execute(task); executor.execute(task);
} catch (Throwable t) { } 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);
} }
} }