From 00ea39b754e739b3afe45fc633ce5b07469373cf Mon Sep 17 00:00:00 2001 From: Dan Homola Date: Wed, 12 Aug 2026 16:44:28 +0200 Subject: [PATCH 1/2] MINOR: actually throw in PooledByteBufAllocatorL There was a check in that class that looks like it throws an exception, but actually does not. This means that when that branch is hit, instead of an actionable error, the user gets a ClassCastException like ``` java.lang.ClassCastException: class io.netty.buffer.PooledDirectByteBuf cannot be cast to class io.netty.buffer.PooledUnsafeDirectByteBuf (io.netty.buffer.PooledDirectByteBuf and io.netty.buffer.PooledUnsafeDirectByteBuf are in unnamed module of loader org.springframework.boot.loader.launch.LaunchedClassLoader@5e9f23b4) ``` Actually throwing the exception prevents this. --- .../src/main/java/io/netty/buffer/PooledByteBufAllocatorL.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/memory/memory-netty-buffer-patch/src/main/java/io/netty/buffer/PooledByteBufAllocatorL.java b/memory/memory-netty-buffer-patch/src/main/java/io/netty/buffer/PooledByteBufAllocatorL.java index b3d79c34ce..785ab60509 100644 --- a/memory/memory-netty-buffer-patch/src/main/java/io/netty/buffer/PooledByteBufAllocatorL.java +++ b/memory/memory-netty-buffer-patch/src/main/java/io/netty/buffer/PooledByteBufAllocatorL.java @@ -172,7 +172,7 @@ private UnsafeDirectLittleEndian newDirectBufferL(int initialCapacity, int maxCa // within chunk, use arena. ByteBuf buf = directArena.allocate(cache, initialCapacity, maxCapacity); if (!(buf instanceof PooledUnsafeDirectByteBuf)) { - fail(); + throw fail(); } if (!AssertionUtil.ASSERT_ENABLED) { From 8b25da1d276af71f2cb61264aeca70933f9a6605 Mon Sep 17 00:00:00 2001 From: Dan Homola Date: Wed, 12 Aug 2026 16:57:12 +0200 Subject: [PATCH 2/2] MINOR: fix getNormalBufferCount This used to return size, which is wrong. --- .../src/main/java/io/netty/buffer/PooledByteBufAllocatorL.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/memory/memory-netty-buffer-patch/src/main/java/io/netty/buffer/PooledByteBufAllocatorL.java b/memory/memory-netty-buffer-patch/src/main/java/io/netty/buffer/PooledByteBufAllocatorL.java index 785ab60509..44031a2d4f 100644 --- a/memory/memory-netty-buffer-patch/src/main/java/io/netty/buffer/PooledByteBufAllocatorL.java +++ b/memory/memory-netty-buffer-patch/src/main/java/io/netty/buffer/PooledByteBufAllocatorL.java @@ -82,7 +82,7 @@ public long getNormalBufferSize() { } public long getNormalBufferCount() { - return normalBufferSize.get(); + return normalBufferCount.get(); } private static class AccountedUnsafeDirectLittleEndian extends UnsafeDirectLittleEndian {