From a7c73d2e52535abe93e40daccbdb133bb41014fc Mon Sep 17 00:00:00 2001 From: Trustin Lee Date: Mon, 18 Aug 2008 11:11:55 +0000 Subject: [PATCH] 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 --- .../netty/channel/DefaultChannelPipeline.java | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/src/main/java/org/jboss/netty/channel/DefaultChannelPipeline.java b/src/main/java/org/jboss/netty/channel/DefaultChannelPipeline.java index 2621dfbe6f..0fb651f40e 100644 --- a/src/main/java/org/jboss/netty/channel/DefaultChannelPipeline.java +++ b/src/main/java/org/jboss/netty/channel/DefaultChannelPipeline.java @@ -358,7 +358,7 @@ public class DefaultChannelPipeline implements ChannelPipeline { try { ((ChannelUpstreamHandler) ctx.getHandler()).handleUpstream(ctx, e); } catch (Throwable t) { - notifyException(e, t); + notifyHandlerException(e, t); } } @@ -369,7 +369,7 @@ public class DefaultChannelPipeline implements ChannelPipeline { getSink().eventSunk(this, e); return; } catch (Throwable t) { - notifyException(e, t); + notifyHandlerException(e, t); } } @@ -380,7 +380,7 @@ public class DefaultChannelPipeline implements ChannelPipeline { try { ((ChannelDownstreamHandler) ctx.getHandler()).handleDownstream(ctx, e); } catch (Throwable t) { - notifyException(e, t); + notifyHandlerException(e, t); } } @@ -416,7 +416,14 @@ public class DefaultChannelPipeline implements ChannelPipeline { 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; if (t instanceof ChannelPipelineException) { pe = (ChannelPipelineException) t; @@ -561,7 +568,7 @@ public class DefaultChannelPipeline implements ChannelPipeline { try { getSink().eventSunk(DefaultChannelPipeline.this, e); } catch (Throwable t) { - notifyException(e, t); + notifyHandlerException(e, t); } } else { DefaultChannelPipeline.this.sendDownstream(prev, e);