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 7b0b56eedc..4f2a538c1e 100644 --- a/handler/src/main/java/io/netty/handler/traffic/AbstractTrafficShapingHandler.java +++ b/handler/src/main/java/io/netty/handler/traffic/AbstractTrafficShapingHandler.java @@ -143,13 +143,7 @@ public abstract class AbstractTrafficShapingHandler extends ChannelDuplexHandler * {@value #GLOBALCHANNEL_DEFAULT_USER_DEFINED_WRITABILITY_INDEX}. */ protected int userDefinedWritabilityIndex() { - if (this instanceof GlobalChannelTrafficShapingHandler) { - return GLOBALCHANNEL_DEFAULT_USER_DEFINED_WRITABILITY_INDEX; - } else if (this instanceof GlobalTrafficShapingHandler) { - return GLOBAL_DEFAULT_USER_DEFINED_WRITABILITY_INDEX; - } else { - return CHANNEL_DEFAULT_USER_DEFINED_WRITABILITY_INDEX; - } + return CHANNEL_DEFAULT_USER_DEFINED_WRITABILITY_INDEX; } /** 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 6c4fc58291..a716560a8c 100644 --- a/handler/src/main/java/io/netty/handler/traffic/GlobalTrafficShapingHandler.java +++ b/handler/src/main/java/io/netty/handler/traffic/GlobalTrafficShapingHandler.java @@ -111,6 +111,11 @@ public class GlobalTrafficShapingHandler extends AbstractTrafficShapingHandler { tc.start(); } + @Override + protected int userDefinedWritabilityIndex() { + return AbstractTrafficShapingHandler.GLOBAL_DEFAULT_USER_DEFINED_WRITABILITY_INDEX; + } + /** * Create a new instance. *