From 2f08f0d58cb15a5038dbd93436eb895f36b9e2d4 Mon Sep 17 00:00:00 2001 From: Nassim Jahnke Date: Wed, 27 Nov 2024 11:32:03 +0100 Subject: [PATCH] Set max capacity for remaining buf This allows the returned buffer to be a cached empty buf if the original buffer was already fully read --- .../viaversion/viaversion/connection/UserConnectionImpl.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/common/src/main/java/com/viaversion/viaversion/connection/UserConnectionImpl.java b/common/src/main/java/com/viaversion/viaversion/connection/UserConnectionImpl.java index 35f4b9ab0..7f1f645e0 100644 --- a/common/src/main/java/com/viaversion/viaversion/connection/UserConnectionImpl.java +++ b/common/src/main/java/com/viaversion/viaversion/connection/UserConnectionImpl.java @@ -373,7 +373,7 @@ public class UserConnectionImpl implements UserConnection { // Instead of allocating a possible unnecessarily large buffer to write the wrapper contents to, // only allocate the remaining bytes and write the rest to the original buf's head directly. - final ByteBuf remainingBuf = buf.alloc().buffer(remainingBytes); + final ByteBuf remainingBuf = buf.alloc().buffer(remainingBytes, remainingBytes); try { // Copy before modifying the buffer remainingBuf.writeBytes(buf, remainingBytes);