From eaaa439c678f6b72432bc82c5090b4e35f1ce59e Mon Sep 17 00:00:00 2001 From: Frederic Bregier Date: Sat, 20 Sep 2014 19:07:23 +0200 Subject: [PATCH] Fix overriden method not called in TrafficShaping Motivation: handlerAdded and handlerRemoved were overriden but super was never called, while it should. Also add one missing information in the toString method. Modifications: Add the super corresponding call, and add checkInterval to the toString() method Result; super method calls are correctly passed to the super implementation part. --- .../handler/traffic/AbstractTrafficShapingHandler.java | 6 +++--- .../netty/handler/traffic/ChannelTrafficShapingHandler.java | 2 ++ .../netty/handler/traffic/GlobalTrafficShapingHandler.java | 2 ++ 3 files changed, 7 insertions(+), 3 deletions(-) diff --git a/handler/src/main/java/io/netty/handler/traffic/AbstractTrafficShapingHandler.java b/handler/src/main/java/io/netty/handler/traffic/AbstractTrafficShapingHandler.java index 342ec86df5..4457a52761 100644 --- a/handler/src/main/java/io/netty/handler/traffic/AbstractTrafficShapingHandler.java +++ b/handler/src/main/java/io/netty/handler/traffic/AbstractTrafficShapingHandler.java @@ -411,9 +411,9 @@ public abstract class AbstractTrafficShapingHandler extends ChannelHandlerAdapte @Override public String toString() { - return "TrafficShaping with Write Limit: " + writeLimit + - " Read Limit: " + readLimit + " and Counter: " + - (trafficCounter != null? trafficCounter.toString() : "none"); + return "TrafficShaping with Write Limit: " + writeLimit + " Read Limit: " + readLimit + + " CheckInterval: " + checkInterval + " and Counter: " + + (trafficCounter != null ? trafficCounter.toString() : "none"); } /** diff --git a/handler/src/main/java/io/netty/handler/traffic/ChannelTrafficShapingHandler.java b/handler/src/main/java/io/netty/handler/traffic/ChannelTrafficShapingHandler.java index 0e4d73893c..c4724faabc 100644 --- a/handler/src/main/java/io/netty/handler/traffic/ChannelTrafficShapingHandler.java +++ b/handler/src/main/java/io/netty/handler/traffic/ChannelTrafficShapingHandler.java @@ -117,6 +117,7 @@ public class ChannelTrafficShapingHandler extends AbstractTrafficShapingHandler ctx.channel().hashCode(), checkInterval); setTrafficCounter(trafficCounter); trafficCounter.start(); + super.handlerAdded(ctx); } @Override @@ -130,6 +131,7 @@ public class ChannelTrafficShapingHandler extends AbstractTrafficShapingHandler } } messagesQueue.clear(); + super.handlerRemoved(ctx); } private static final class ToSend { diff --git a/handler/src/main/java/io/netty/handler/traffic/GlobalTrafficShapingHandler.java b/handler/src/main/java/io/netty/handler/traffic/GlobalTrafficShapingHandler.java index a73c6d3978..d47c2b0123 100644 --- a/handler/src/main/java/io/netty/handler/traffic/GlobalTrafficShapingHandler.java +++ b/handler/src/main/java/io/netty/handler/traffic/GlobalTrafficShapingHandler.java @@ -172,6 +172,7 @@ public class GlobalTrafficShapingHandler extends AbstractTrafficShapingHandler { Integer key = ctx.channel().hashCode(); List mq = new LinkedList(); messagesQueues.put(key, mq); + super.handlerAdded(ctx); } @Override @@ -186,6 +187,7 @@ public class GlobalTrafficShapingHandler extends AbstractTrafficShapingHandler { } mq.clear(); } + super.handlerRemoved(ctx); } private static final class ToSend {