diff --git a/spring-core/src/test/java/org/springframework/core/io/buffer/DataBufferTests.java b/spring-core/src/test/java/org/springframework/core/io/buffer/DataBufferTests.java index 45dc7e7a53..1739a47229 100644 --- a/spring-core/src/test/java/org/springframework/core/io/buffer/DataBufferTests.java +++ b/spring-core/src/test/java/org/springframework/core/io/buffer/DataBufferTests.java @@ -807,14 +807,14 @@ class DataBufferTests extends AbstractDataBufferAllocatingTests { DataBuffer buffer2 = createDataBuffer(1); buffer2.write(new byte[]{'a'}); - split = buffer2.split(1); + DataBuffer split2 = buffer2.split(1); - assertThat(split.readPosition()).isEqualTo(0); - assertThat(split.writePosition()).isEqualTo(1); - assertThat(split.capacity()).isEqualTo(1); - assertThat(split.readableByteCount()).isEqualTo(1); + assertThat(split2.readPosition()).isEqualTo(0); + assertThat(split2.writePosition()).isEqualTo(1); + assertThat(split2.capacity()).isEqualTo(1); + assertThat(split2.readableByteCount()).isEqualTo(1); bytes = new byte[1]; - split.read(bytes); + split2.read(bytes); assertThat(bytes).containsExactly('a'); assertThat(buffer2.readPosition()).isEqualTo(0); @@ -822,7 +822,7 @@ class DataBufferTests extends AbstractDataBufferAllocatingTests { assertThat(buffer2.capacity()).isEqualTo(0); assertThat(buffer.readableByteCount()).isEqualTo(0); - release(buffer, buffer2); + release(buffer, buffer2, split, split2); } @ParameterizedDataBufferAllocatingTest diff --git a/spring-core/src/testFixtures/java/org/springframework/core/testfixture/io/buffer/AbstractDataBufferAllocatingTests.java b/spring-core/src/testFixtures/java/org/springframework/core/testfixture/io/buffer/AbstractDataBufferAllocatingTests.java index 47d18ffd66..2ad1a834a1 100644 --- a/spring-core/src/testFixtures/java/org/springframework/core/testfixture/io/buffer/AbstractDataBufferAllocatingTests.java +++ b/spring-core/src/testFixtures/java/org/springframework/core/testfixture/io/buffer/AbstractDataBufferAllocatingTests.java @@ -164,26 +164,29 @@ public abstract class AbstractDataBufferAllocatingTests { @SuppressWarnings("deprecation") // PooledByteBufAllocator no longer supports tinyCacheSize. public static Stream dataBufferFactories() { return Stream.of( -// arguments(named("NettyDataBufferFactory - UnpooledByteBufAllocator - preferDirect = true", -// new NettyDataBufferFactory(new UnpooledByteBufAllocator(true)))), + // Netty 4 + arguments(named("NettyDataBufferFactory - UnpooledByteBufAllocator - preferDirect = true", + new NettyDataBufferFactory(new UnpooledByteBufAllocator(true)))), arguments(named("NettyDataBufferFactory - UnpooledByteBufAllocator - preferDirect = false", new NettyDataBufferFactory(new UnpooledByteBufAllocator(false)))), // 1) Disable caching for reliable leak detection, see https://github.com/netty/netty/issues/5275 // 2) maxOrder is 4 (vs default 11) but can be increased if necessary -// arguments(named("NettyDataBufferFactory - PooledByteBufAllocator - preferDirect = true", -// new NettyDataBufferFactory(new PooledByteBufAllocator(true, 1, 1, 4096, 4, 0, 0, 0, true)))), -// arguments(named("NettyDataBufferFactory - PooledByteBufAllocator - preferDirect = false", -// new NettyDataBufferFactory(new PooledByteBufAllocator(false, 1, 1, 4096, 4, 0, 0, 0, true)))), + arguments(named("NettyDataBufferFactory - PooledByteBufAllocator - preferDirect = true", + new NettyDataBufferFactory(new PooledByteBufAllocator(true, 1, 1, 4096, 4, 0, 0, 0, true)))), + arguments(named("NettyDataBufferFactory - PooledByteBufAllocator - preferDirect = false", + new NettyDataBufferFactory(new PooledByteBufAllocator(false, 1, 1, 4096, 4, 0, 0, 0, true)))), + // Netty 5 arguments(named("Netty5DataBufferFactory - BufferAllocator.onHeapUnpooled()", new Netty5DataBufferFactory(BufferAllocator.onHeapUnpooled()))), -// arguments(named("Netty5DataBufferFactory - BufferAllocator.offHeapUnpooled()", -// new Netty5DataBufferFactory(BufferAllocator.offHeapUnpooled()))), -// arguments(named("Netty5DataBufferFactory - BufferAllocator.onHeapPooled()", -// new Netty5DataBufferFactory(BufferAllocator.onHeapPooled()))), -// arguments(named("Netty5DataBufferFactory - BufferAllocator.offHeapPooled()", -// new Netty5DataBufferFactory(BufferAllocator.offHeapPooled()))), -// arguments(named("DefaultDataBufferFactory - preferDirect = true", -// new DefaultDataBufferFactory(true))), + arguments(named("Netty5DataBufferFactory - BufferAllocator.offHeapUnpooled()", + new Netty5DataBufferFactory(BufferAllocator.offHeapUnpooled()))), + arguments(named("Netty5DataBufferFactory - BufferAllocator.onHeapPooled()", + new Netty5DataBufferFactory(BufferAllocator.onHeapPooled()))), + arguments(named("Netty5DataBufferFactory - BufferAllocator.offHeapPooled()", + new Netty5DataBufferFactory(BufferAllocator.offHeapPooled()))), + // Default + arguments(named("DefaultDataBufferFactory - preferDirect = true", + new DefaultDataBufferFactory(true))), arguments(named("DefaultDataBufferFactory - preferDirect = false", new DefaultDataBufferFactory(false))) );