Trigger exceptionCaught() when VoidChannelPromise fails

Related: #3190

Motivation:

When an outbound handler method raises an exception, its promise is
marked as failed.  If the promise is done already, the exception is
logged.

When the promise is void, exceptionCaught() must be triggered to notify
a user. However, ChannelHandlerInvokerUtil simply swallows it.

Modifications:

Do not swallow an exception when the promise is void.

Result:

A user who uses a void promise for an outbound operation will be
notified on failure.
This commit is contained in:
Trustin Lee 2014-12-07 16:00:35 +09:00
parent 7e2ae8758c
commit a337589c91

View File

@ -220,13 +220,7 @@ public final class ChannelHandlerInvokerUtil {
} }
private static void notifyOutboundHandlerException(Throwable cause, ChannelPromise promise) { private static void notifyOutboundHandlerException(Throwable cause, ChannelPromise promise) {
// only try to fail the promise if its not a VoidChannelPromise, as if (!promise.tryFailure(cause) && !(promise instanceof VoidChannelPromise)) {
// the VoidChannelPromise would also fire the cause through the pipeline
if (promise instanceof VoidChannelPromise) {
return;
}
if (!promise.tryFailure(cause)) {
if (logger.isWarnEnabled()) { if (logger.isWarnEnabled()) {
logger.warn("Failed to fail the promise because it's done already: {}", promise, cause); logger.warn("Failed to fail the promise because it's done already: {}", promise, cause);
} }