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.
This commit is contained in:
Trustin Lee 2014-12-07 16:00:35 +09:00
parent 2fadef31ef
commit 1122189771

View File

@ -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);
}