From 9db454ffe5128e03f9d952b1555a339ffd759326 Mon Sep 17 00:00:00 2001 From: Chris Vest Date: Fri, 7 May 2021 12:02:55 +0200 Subject: [PATCH] Fix composite buffer send bug Fix a bug in CompositeBuffer.send, where the received buffer would not have ownership. The fix is to avoid incrementing the reference count in the composite buffer constructor call used in the transferOwnership function. --- src/main/java/io/netty/buffer/api/CompositeBuffer.java | 2 +- .../java/io/netty/buffer/api/BufferReferenceCountingTest.java | 1 - 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/src/main/java/io/netty/buffer/api/CompositeBuffer.java b/src/main/java/io/netty/buffer/api/CompositeBuffer.java index 2b45ada..3824b58 100644 --- a/src/main/java/io/netty/buffer/api/CompositeBuffer.java +++ b/src/main/java/io/netty/buffer/api/CompositeBuffer.java @@ -1351,7 +1351,7 @@ public final class CompositeBuffer extends RcSupport im for (int i = 0; i < sends.length; i++) { received[i] = sends[i].receive(); } - var composite = new CompositeBuffer(allocator, received, drop, true); + var composite = new CompositeBuffer(allocator, received, drop, false); composite.readOnly = readOnly; drop.attach(composite); return composite; diff --git a/src/test/java/io/netty/buffer/api/BufferReferenceCountingTest.java b/src/test/java/io/netty/buffer/api/BufferReferenceCountingTest.java index 010abd3..15338b5 100644 --- a/src/test/java/io/netty/buffer/api/BufferReferenceCountingTest.java +++ b/src/test/java/io/netty/buffer/api/BufferReferenceCountingTest.java @@ -350,7 +350,6 @@ public class BufferReferenceCountingTest extends BufferTestSupport { } } - @Disabled // TODO @ParameterizedTest @MethodSource("allocators") public void sliceMustBecomeOwnedOnSourceBufferClose(Fixture fixture) {