Fixed issue: NETTY-13 (Stack overflow when an exception is thrown while processing ExceptionEvent)

* Renamed notifyException to notifyHandlerException
* Prevented infinite recursion caused by failure on exceptionCaught
This commit is contained in:
Trustin Lee 2008-08-18 11:11:55 +00:00
parent a05905f64a
commit a7c73d2e52

View File

@ -358,7 +358,7 @@ public class DefaultChannelPipeline implements ChannelPipeline {
try { try {
((ChannelUpstreamHandler) ctx.getHandler()).handleUpstream(ctx, e); ((ChannelUpstreamHandler) ctx.getHandler()).handleUpstream(ctx, e);
} catch (Throwable t) { } catch (Throwable t) {
notifyException(e, t); notifyHandlerException(e, t);
} }
} }
@ -369,7 +369,7 @@ public class DefaultChannelPipeline implements ChannelPipeline {
getSink().eventSunk(this, e); getSink().eventSunk(this, e);
return; return;
} catch (Throwable t) { } catch (Throwable t) {
notifyException(e, t); notifyHandlerException(e, t);
} }
} }
@ -380,7 +380,7 @@ public class DefaultChannelPipeline implements ChannelPipeline {
try { try {
((ChannelDownstreamHandler) ctx.getHandler()).handleDownstream(ctx, e); ((ChannelDownstreamHandler) ctx.getHandler()).handleDownstream(ctx, e);
} catch (Throwable t) { } catch (Throwable t) {
notifyException(e, t); notifyHandlerException(e, t);
} }
} }
@ -416,7 +416,14 @@ public class DefaultChannelPipeline implements ChannelPipeline {
return realCtx; return realCtx;
} }
void notifyException(ChannelEvent e, Throwable t) { void notifyHandlerException(ChannelEvent e, Throwable t) {
if (e instanceof ExceptionEvent) {
logger.warn(
"An exception was thrown by a user handler " +
"while handling an exception event (" + e + ")", t);
return;
}
ChannelPipelineException pe; ChannelPipelineException pe;
if (t instanceof ChannelPipelineException) { if (t instanceof ChannelPipelineException) {
pe = (ChannelPipelineException) t; pe = (ChannelPipelineException) t;
@ -561,7 +568,7 @@ public class DefaultChannelPipeline implements ChannelPipeline {
try { try {
getSink().eventSunk(DefaultChannelPipeline.this, e); getSink().eventSunk(DefaultChannelPipeline.this, e);
} catch (Throwable t) { } catch (Throwable t) {
notifyException(e, t); notifyHandlerException(e, t);
} }
} else { } else {
DefaultChannelPipeline.this.sendDownstream(prev, e); DefaultChannelPipeline.this.sendDownstream(prev, e);