diff --git a/transport/src/main/java/io/netty/channel/AbstractChannel.java b/transport/src/main/java/io/netty/channel/AbstractChannel.java index 1038f0a65c..b8be06bec3 100644 --- a/transport/src/main/java/io/netty/channel/AbstractChannel.java +++ b/transport/src/main/java/io/netty/channel/AbstractChannel.java @@ -18,8 +18,8 @@ package io.netty.channel; import io.netty.buffer.ByteBuf; import io.netty.buffer.ByteBufAllocator; import io.netty.buffer.ByteBufHolder; -import io.netty.buffer.ByteBufUtil; import io.netty.util.DefaultAttributeMap; +import io.netty.util.ReferenceCountUtil; import io.netty.util.internal.PlatformDependent; import io.netty.util.internal.logging.InternalLogger; import io.netty.util.internal.logging.InternalLoggerFactory; @@ -715,7 +715,7 @@ public abstract class AbstractChannel extends DefaultAttributeMap implements Cha if (promise.isCancelled()) { // If cancelled, release all unwritten messages and recycle. for (int i = messageIndex; i < messageCount; i ++) { - ByteBufUtil.release(messages.get(i)); + ReferenceCountUtil.release(messages.get(i)); } messages.recycle(); if (!outboundBuffer.next()) { diff --git a/transport/src/main/java/io/netty/channel/AbstractServerChannel.java b/transport/src/main/java/io/netty/channel/AbstractServerChannel.java index 9334aa676f..7d135c638d 100755 --- a/transport/src/main/java/io/netty/channel/AbstractServerChannel.java +++ b/transport/src/main/java/io/netty/channel/AbstractServerChannel.java @@ -15,7 +15,7 @@ */ package io.netty.channel; -import io.netty.buffer.ByteBufUtil; +import io.netty.util.ReferenceCountUtil; import java.net.SocketAddress; @@ -81,7 +81,7 @@ public abstract class AbstractServerChannel extends AbstractChannel implements S reject(promise); int size = msgs.size(); for (int i = 0; i < size; i ++) { - ByteBufUtil.release(msgs.get(i)); + ReferenceCountUtil.release(msgs.get(i)); } } diff --git a/transport/src/main/java/io/netty/channel/ChannelOutboundBuffer.java b/transport/src/main/java/io/netty/channel/ChannelOutboundBuffer.java index 4744fa4a98..dd69719cee 100644 --- a/transport/src/main/java/io/netty/channel/ChannelOutboundBuffer.java +++ b/transport/src/main/java/io/netty/channel/ChannelOutboundBuffer.java @@ -19,7 +19,7 @@ */ package io.netty.channel; -import io.netty.buffer.ByteBufUtil; +import io.netty.util.ReferenceCountUtil; import io.netty.util.internal.logging.InternalLogger; import io.netty.util.internal.logging.InternalLoggerFactory; @@ -228,7 +228,7 @@ final class ChannelOutboundBuffer { try { for (int i = currentMessageIndex; i < currentMessages.size(); i++) { Object msg = currentMessages.get(i); - ByteBufUtil.release(msg); + ReferenceCountUtil.release(msg); } } finally { currentMessages.recycle(); diff --git a/transport/src/main/java/io/netty/channel/DefaultChannelPipeline.java b/transport/src/main/java/io/netty/channel/DefaultChannelPipeline.java index 4a099291a4..f6fe786ae8 100755 --- a/transport/src/main/java/io/netty/channel/DefaultChannelPipeline.java +++ b/transport/src/main/java/io/netty/channel/DefaultChannelPipeline.java @@ -15,8 +15,8 @@ */ package io.netty.channel; -import io.netty.buffer.ByteBufUtil; import io.netty.channel.Channel.Unsafe; +import io.netty.util.ReferenceCountUtil; import io.netty.util.concurrent.EventExecutor; import io.netty.util.concurrent.EventExecutorGroup; import io.netty.util.internal.PlatformDependent; @@ -970,7 +970,7 @@ final class DefaultChannelPipeline implements ChannelPipeline { "Discarded inbound message {} that reached at the tail of the pipeline. " + "Please check your pipeline configuration.", m); - ByteBufUtil.release(m); + ReferenceCountUtil.release(m); } if (length != 1) { diff --git a/transport/src/main/java/io/netty/channel/MultithreadEventLoopGroup.java b/transport/src/main/java/io/netty/channel/MultithreadEventLoopGroup.java index 3586a3a4b6..ab27b219b3 100644 --- a/transport/src/main/java/io/netty/channel/MultithreadEventLoopGroup.java +++ b/transport/src/main/java/io/netty/channel/MultithreadEventLoopGroup.java @@ -31,7 +31,7 @@ public abstract class MultithreadEventLoopGroup extends MultithreadEventExecutor private static final InternalLogger logger = InternalLoggerFactory.getInstance(MultithreadEventLoopGroup.class); - public static final int DEFAULT_EVENT_LOOP_THREADS; + private static final int DEFAULT_EVENT_LOOP_THREADS; static { DEFAULT_EVENT_LOOP_THREADS = Math.max(1, SystemPropertyUtil.getInt( @@ -43,7 +43,7 @@ public abstract class MultithreadEventLoopGroup extends MultithreadEventExecutor } protected MultithreadEventLoopGroup(int nThreads, ThreadFactory threadFactory, Object... args) { - super(nThreads, threadFactory, args); + super(nThreads == 0? DEFAULT_EVENT_LOOP_THREADS : nThreads, threadFactory, args); } @Override diff --git a/transport/src/main/java/io/netty/channel/local/LocalEventLoopGroup.java b/transport/src/main/java/io/netty/channel/local/LocalEventLoopGroup.java index 2f32bb4258..dd3c7d316b 100644 --- a/transport/src/main/java/io/netty/channel/local/LocalEventLoopGroup.java +++ b/transport/src/main/java/io/netty/channel/local/LocalEventLoopGroup.java @@ -26,10 +26,10 @@ import java.util.concurrent.ThreadFactory; public class LocalEventLoopGroup extends MultithreadEventLoopGroup { /** - * Create a new instance which used {@link #DEFAULT_EVENT_LOOP_THREADS} number of Threads + * Create a new instance with the default number of threads. */ public LocalEventLoopGroup() { - this(DEFAULT_EVENT_LOOP_THREADS); + this(0); } /** diff --git a/transport/src/main/java/io/netty/channel/nio/NioEventLoopGroup.java b/transport/src/main/java/io/netty/channel/nio/NioEventLoopGroup.java index 04d89b68fa..96eb461eff 100644 --- a/transport/src/main/java/io/netty/channel/nio/NioEventLoopGroup.java +++ b/transport/src/main/java/io/netty/channel/nio/NioEventLoopGroup.java @@ -29,15 +29,15 @@ import java.util.concurrent.ThreadFactory; public class NioEventLoopGroup extends MultithreadEventLoopGroup { /** - * Create a new instance using {@link #DEFAULT_EVENT_LOOP_THREADS} number of threads, the default - * {@link ThreadFactory} and the {@link SelectorProvider} which is returned by {@link SelectorProvider#provider()}. + * Create a new instance using the default number of threads, the default {@link ThreadFactory} and + * the {@link SelectorProvider} which is returned by {@link SelectorProvider#provider()}. */ public NioEventLoopGroup() { - this(DEFAULT_EVENT_LOOP_THREADS); + this(0); } /** - * Create a new instance using nThreads number of threads, {@link ThreadFactory} and the + * Create a new instance using the specified number of threads, {@link ThreadFactory} and the * {@link SelectorProvider} which is returned by {@link SelectorProvider#provider()}. */ public NioEventLoopGroup(int nThreads) { @@ -45,7 +45,7 @@ public class NioEventLoopGroup extends MultithreadEventLoopGroup { } /** - * Create a new instance using nThreads number of threads, the given {@link ThreadFactory} and the + * Create a new instance using the specified number of threads, the given {@link ThreadFactory} and the * {@link SelectorProvider} which is returned by {@link SelectorProvider#provider()}. */ public NioEventLoopGroup(int nThreads, ThreadFactory threadFactory) { @@ -53,7 +53,7 @@ public class NioEventLoopGroup extends MultithreadEventLoopGroup { } /** - * Create a new instance using nThreads number of threads, the given {@link ThreadFactory} and the given + * Create a new instance using the specified number of threads, the given {@link ThreadFactory} and the given * {@link SelectorProvider}. */ public NioEventLoopGroup(