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 a804c3495e
commit 483f093036
2 changed files with 12 additions and 0 deletions

View File

@ -571,6 +571,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

@ -388,6 +388,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);
}
}