From a337589c91e680bd0026c23a45e9d747069af887 Mon Sep 17 00:00:00 2001 From: Trustin Lee Date: Sun, 7 Dec 2014 16:00:35 +0900 Subject: [PATCH] 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. --- .../java/io/netty/channel/ChannelHandlerInvokerUtil.java | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/transport/src/main/java/io/netty/channel/ChannelHandlerInvokerUtil.java b/transport/src/main/java/io/netty/channel/ChannelHandlerInvokerUtil.java index c820cd649e..abf6f6c6e2 100644 --- a/transport/src/main/java/io/netty/channel/ChannelHandlerInvokerUtil.java +++ b/transport/src/main/java/io/netty/channel/ChannelHandlerInvokerUtil.java @@ -220,13 +220,7 @@ public final class ChannelHandlerInvokerUtil { } private static void notifyOutboundHandlerException(Throwable cause, ChannelPromise promise) { - // only try to fail the promise if its not a VoidChannelPromise, as - // the VoidChannelPromise would also fire the cause through the pipeline - if (promise instanceof VoidChannelPromise) { - return; - } - - if (!promise.tryFailure(cause)) { + if (!promise.tryFailure(cause) && !(promise instanceof VoidChannelPromise)) { if (logger.isWarnEnabled()) { logger.warn("Failed to fail the promise because it's done already: {}", promise, cause); }