NETTY-415 ChannelFuture.setFailure() not called when exception thrown handling Channel.close()

* Made sure the ChannelFuture associated with a downstream event is marked as failure when an exception is raised before it reaches at ChannelSink.
This commit is contained in:
Trustin Lee 2011-08-02 06:35:38 +09:00
parent 95f3af0a02
commit 5579a91e1d
2 changed files with 12 additions and 0 deletions

View File

@ -597,6 +597,12 @@ public class DefaultChannelPipeline implements ChannelPipeline {
try {
((ChannelDownstreamHandler) ctx.getHandler()).handleDownstream(ctx, e);
} catch (Throwable t) {
// Unlike an upstream event, a downstream event usually has an
// incomplete future which is supposed to be updated by ChannelSink.
// However, if an exception is raised before the event reaches at
// ChannelSink, the future is not going to be updated, so we update
// here.
e.getFuture().setFailure(t);
notifyHandlerException(e, t);
}
}

View File

@ -414,6 +414,12 @@ public class StaticChannelPipeline implements ChannelPipeline {
try {
((ChannelDownstreamHandler) ctx.getHandler()).handleDownstream(ctx, e);
} catch (Throwable t) {
// Unlike an upstream event, a downstream event usually has an
// incomplete future which is supposed to be updated by ChannelSink.
// However, if an exception is raised before the event reaches at
// ChannelSink, the future is not going to be updated, so we update
// here.
e.getFuture().setFailure(t);
notifyHandlerException(e, t);
}
}