Skip to content

Commit

Permalink
Fix default value for maxCachedBufferCapacity in NettyByteBufLeakHelp…
Browse files Browse the repository at this point in the history
…er (#1381)

The cache is actually enabled by default if the property is not set.
Use a default value copied from the netty source.
  • Loading branch information
cgtz committed Feb 11, 2020
1 parent 3f35448 commit 6f407d1
Showing 1 changed file with 4 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
import io.netty.buffer.PoolArenaMetric;
import io.netty.buffer.PooledByteBufAllocator;
import io.netty.buffer.PooledByteBufAllocatorMetric;
import io.netty.util.internal.SystemPropertyUtil;
import java.util.List;
import org.junit.Assert;

Expand All @@ -42,7 +43,9 @@ public class NettyByteBufLeakHelper {
* Constructor to create a {@link NettyByteBufLeakHelper}.
*/
public NettyByteBufLeakHelper() {
cachedEnabled = Integer.parseInt(System.getProperty("io.netty.allocator.maxCachedBufferCapacity", "0")) != 0;
// The allocator cache is enabled by default if this property is not set. The default value of 32k comes from
// PooledByteBufAllocator.DEFAULT_MAX_CACHED_BUFFER_CAPACITY (private constant)
cachedEnabled = SystemPropertyUtil.getInt("io.netty.allocator.maxCachedBufferCapacity", 32 * 1024) != 0;
}

/**
Expand Down

0 comments on commit 6f407d1

Please sign in to comment.