From 4630905b92b1cfbf2ce414ba1c9e802cdf4b9e63 Mon Sep 17 00:00:00 2001 From: Trustin Lee Date: Mon, 4 Jun 2012 12:10:13 -0700 Subject: [PATCH] Do not wrap exceptions if possible --- .../netty/channel/DefaultChannelPipeline.java | 54 ++++++++++++------- 1 file changed, 35 insertions(+), 19 deletions(-) diff --git a/transport/src/main/java/io/netty/channel/DefaultChannelPipeline.java b/transport/src/main/java/io/netty/channel/DefaultChannelPipeline.java index b130e620ae..2b100133f2 100644 --- a/transport/src/main/java/io/netty/channel/DefaultChannelPipeline.java +++ b/transport/src/main/java/io/netty/channel/DefaultChannelPipeline.java @@ -97,10 +97,13 @@ public class DefaultChannelPipeline implements ChannelPipeline { addFirst0(name, nextCtx, newCtx); } }).get(); + } catch (RuntimeException e) { + throw e; + } catch (Error e) { + throw e; } catch (Throwable t) { - throw new ChannelException(t); + throw new ChannelPipelineException(t); } - } return this; @@ -141,10 +144,13 @@ public class DefaultChannelPipeline implements ChannelPipeline { addLast0(name, oldTail, newTail); } }).get(); + } catch (RuntimeException e) { + throw e; + } catch (Error e) { + throw e; } catch (Throwable t) { - throw new ChannelException(t); + throw new ChannelPipelineException(t); } - } return this; } @@ -182,8 +188,12 @@ public class DefaultChannelPipeline implements ChannelPipeline { addBefore0(name, ctx, newCtx); } }).get(); + } catch (RuntimeException e) { + throw e; + } catch (Error e) { + throw e; } catch (Throwable t) { - throw new ChannelException(t); + throw new ChannelPipelineException(t); } } return this; @@ -225,13 +235,15 @@ public class DefaultChannelPipeline implements ChannelPipeline { addAfter0(name, ctx, newCtx); } }).get(); + } catch (RuntimeException e) { + throw e; + } catch (Error e) { + throw e; } catch (Throwable t) { - throw new ChannelException(t); + throw new ChannelPipelineException(t); } } - } - return this; } @@ -335,18 +347,19 @@ public class DefaultChannelPipeline implements ChannelPipeline { } else { try { ctx.executor().submit(new Runnable() { - @Override public void run() { remove0(ctx); - } }).get(); + } catch (RuntimeException e) { + throw e; + } catch (Error e) { + throw e; } catch (Throwable t) { - throw new ChannelException(t); + throw new ChannelPipelineException(t); } } - } return ctx; } @@ -383,19 +396,19 @@ public class DefaultChannelPipeline implements ChannelPipeline { } else { try { oldTail.executor().submit(new Runnable() { - @Override public void run() { removeLast0(oldTail); - } }).get(); + } catch (RuntimeException e) { + throw e; + } catch (Error e) { + throw e; } catch (Throwable t) { - throw new ChannelException(t); + throw new ChannelPipelineException(t); } - } - return oldTail.handler(); } @@ -451,11 +464,14 @@ public class DefaultChannelPipeline implements ChannelPipeline { @Override public void run() { replace0(ctx, newName, newCtx); - } }).get(); + } catch (RuntimeException e) { + throw e; + } catch (Error e) { + throw e; } catch (Throwable t) { - throw new ChannelException(t); + throw new ChannelPipelineException(t); } } }