|
|
|
@ -35,6 +35,8 @@ import java.util.List; |
|
|
|
import java.util.concurrent.CountDownLatch; |
|
|
|
import java.util.concurrent.CountDownLatch; |
|
|
|
|
|
|
|
|
|
|
|
import io.netty.buffer.ByteBuf; |
|
|
|
import io.netty.buffer.ByteBuf; |
|
|
|
|
|
|
|
import io.netty.buffer.PooledByteBufAllocator; |
|
|
|
|
|
|
|
import org.junit.jupiter.api.Test; |
|
|
|
import org.mockito.stubbing.Answer; |
|
|
|
import org.mockito.stubbing.Answer; |
|
|
|
import org.reactivestreams.Subscription; |
|
|
|
import org.reactivestreams.Subscription; |
|
|
|
import reactor.core.publisher.BaseSubscriber; |
|
|
|
import reactor.core.publisher.BaseSubscriber; |
|
|
|
@ -834,6 +836,22 @@ class DataBufferUtilsTests extends AbstractDataBufferAllocatingTests { |
|
|
|
.verifyError(DataBufferLimitException.class); |
|
|
|
.verifyError(DataBufferLimitException.class); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Test // gh-26060
|
|
|
|
|
|
|
|
void joinWithLimitDoesNotOverRelease() { |
|
|
|
|
|
|
|
NettyDataBufferFactory bufferFactory = new NettyDataBufferFactory(PooledByteBufAllocator.DEFAULT); |
|
|
|
|
|
|
|
byte[] bytes = "foo-bar-baz".getBytes(StandardCharsets.UTF_8); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
NettyDataBuffer buffer = bufferFactory.allocateBuffer(bytes.length); |
|
|
|
|
|
|
|
buffer.getNativeBuffer().retain(); // should be at 2 now
|
|
|
|
|
|
|
|
buffer.write(bytes); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Mono<DataBuffer> result = DataBufferUtils.join(Flux.just(buffer), 8); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
StepVerifier.create(result).verifyError(DataBufferLimitException.class); |
|
|
|
|
|
|
|
assertThat(buffer.getNativeBuffer().refCnt()).isEqualTo(1); |
|
|
|
|
|
|
|
buffer.release(); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@ParameterizedDataBufferAllocatingTest |
|
|
|
@ParameterizedDataBufferAllocatingTest |
|
|
|
void joinErrors(String displayName, DataBufferFactory bufferFactory) { |
|
|
|
void joinErrors(String displayName, DataBufferFactory bufferFactory) { |
|
|
|
super.bufferFactory = bufferFactory; |
|
|
|
super.bufferFactory = bufferFactory; |
|
|
|
|