diff --git a/buffer/src/main/java/io/netty/buffer/PoolArena.java b/buffer/src/main/java/io/netty/buffer/PoolArena.java index ca848d16c0..c4370b9ac6 100644 --- a/buffer/src/main/java/io/netty/buffer/PoolArena.java +++ b/buffer/src/main/java/io/netty/buffer/PoolArena.java @@ -354,6 +354,9 @@ abstract class PoolArena { static final class DirectArena extends PoolArena { + private static final boolean USE_UNSAFE_DIRECTBUF = + PlatformDependent.isUnaligned() && PlatformDependent.unsafeHasCopyMethods(); + DirectArena(PooledByteBufAllocator parent, int pageSize, int maxOrder, int pageShifts, int chunkSize) { super(parent, pageSize, maxOrder, pageShifts, chunkSize); } @@ -376,7 +379,7 @@ abstract class PoolArena { @Override protected PooledByteBuf newByteBuf(int maxCapacity) { - if (PlatformDependent.isUnaligned() && PlatformDependent.unsafeHasCopyMethods()) { + if (USE_UNSAFE_DIRECTBUF) { return new PooledUnsafeDirectByteBuf(maxCapacity); } else { return new PooledDirectByteBuf(maxCapacity);