From 1122189771a88be6ebd87a4482d651092e1d7a7b 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, AbstractChannelHandlerContext 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. --- .../io/netty/channel/AbstractChannelHandlerContext.java | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/transport/src/main/java/io/netty/channel/AbstractChannelHandlerContext.java b/transport/src/main/java/io/netty/channel/AbstractChannelHandlerContext.java index 35fb446e5a..514f614e92 100644 --- a/transport/src/main/java/io/netty/channel/AbstractChannelHandlerContext.java +++ b/transport/src/main/java/io/netty/channel/AbstractChannelHandlerContext.java @@ -717,13 +717,7 @@ abstract class AbstractChannelHandlerContext extends DefaultAttributeMap impleme } 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); }