Warn if the last inbound handler forwarded an exceptionCaught() event

This commit is contained in:
Trustin Lee 2012-05-30 11:48:04 -07:00
parent cca35454d2
commit e5bcc74cd5

View File

@ -668,9 +668,18 @@ public class DefaultChannelPipeline implements ChannelPipeline {
DefaultChannelHandlerContext ctx = firstInboundContext(); DefaultChannelHandlerContext ctx = firstInboundContext();
if (ctx != null) { if (ctx != null) {
fireExceptionCaught(ctx, cause); fireExceptionCaught(ctx, cause);
} else {
logTerminalException(cause);
} }
} }
private static void logTerminalException(Throwable cause) {
logger.warn(
"An exceptionCaught() event was fired, and it reached at the end of the " +
"pipeline. It usually means the last inbound handler in the pipeline did not " +
"handle the exception.", cause);
}
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
private void fireExceptionCaught(DefaultChannelHandlerContext ctx, Throwable cause) { private void fireExceptionCaught(DefaultChannelHandlerContext ctx, Throwable cause) {
if (cause == null) { if (cause == null) {
@ -1270,6 +1279,8 @@ public class DefaultChannelPipeline implements ChannelPipeline {
DefaultChannelHandlerContext next = nextInboundContext(this.next); DefaultChannelHandlerContext next = nextInboundContext(this.next);
if (next != null) { if (next != null) {
DefaultChannelPipeline.this.fireExceptionCaught(next, cause); DefaultChannelPipeline.this.fireExceptionCaught(next, cause);
} else {
logTerminalException(cause);
} }
} }