Review DataBufferUtils for error/cancellation memory leaks

Issue: SPR-17408
This commit is contained in:
Arjen Poutsma
2018-10-19 11:16:26 +02:00
parent 1621125ccf
commit 149d416e8e
2 changed files with 67 additions and 190 deletions

View File

@@ -412,6 +412,20 @@ public class DataBufferUtilsTests extends AbstractDataBufferAllocatingTestCase {
.verify(Duration.ofSeconds(5));
}
@Test
public void takeUntilByteCountErrorInFlux() {
DataBuffer foo = stringBuffer("foo");
Flux<DataBuffer> flux =
Flux.just(foo).concatWith(Mono.error(new RuntimeException()));
Flux<DataBuffer> result = DataBufferUtils.takeUntilByteCount(flux, 5L);
StepVerifier.create(result)
.consumeNextWith(stringConsumer("foo"))
.expectError(RuntimeException.class)
.verify(Duration.ofSeconds(5));
}
@Test
public void takeUntilByteCountExact() {
@@ -444,6 +458,18 @@ public class DataBufferUtilsTests extends AbstractDataBufferAllocatingTestCase {
.verify(Duration.ofSeconds(5));
}
@Test
public void skipUntilByteCountErrorInFlux() {
DataBuffer foo = stringBuffer("foo");
Flux<DataBuffer> flux =
Flux.just(foo).concatWith(Mono.error(new RuntimeException()));
Flux<DataBuffer> result = DataBufferUtils.skipUntilByteCount(flux, 3L);
StepVerifier.create(result)
.expectError(RuntimeException.class)
.verify(Duration.ofSeconds(5));
}
@Test
public void skipUntilByteCountShouldSkipAll() {
DataBuffer foo = stringBuffer("foo");