Removed DataBufferUtils::split

DataBuffers::split (and underlying algorithm) should not be returning
a Flux<DataBuffer>, but rather a Flux<Flux<DataBuffer>>. In other words,
it should not join all data buffers that come before a delimiter.

Providing an implementation of a such a fully reactive split method
proved to be beyond the scope of this release, so this commit removes
the method altogether.
This commit is contained in:
Arjen Poutsma
2019-07-10 13:53:10 +02:00
parent fdcf09dc2f
commit 09572e7b60
2 changed files with 0 additions and 429 deletions

View File

@@ -809,127 +809,6 @@ public class DataBufferUtilsTests extends AbstractDataBufferAllocatingTestCase {
release(foo);
}
@Test
public void split() {
Mono<DataBuffer> source =
deferStringBuffer("--foo--bar--baz--");
byte[] delimiter = "--".getBytes(StandardCharsets.UTF_8);
Flux<DataBuffer> result = DataBufferUtils.split(source, delimiter);
StepVerifier.create(result)
.consumeNextWith(stringConsumer(""))
.consumeNextWith(stringConsumer("foo"))
.consumeNextWith(stringConsumer("bar"))
.consumeNextWith(stringConsumer("baz"))
.verifyComplete();
}
@Test
public void splitIncludeDelimiter() {
Mono<DataBuffer> source =
deferStringBuffer("--foo--bar--baz--");
byte[] delimiter = "--".getBytes(StandardCharsets.UTF_8);
Flux<DataBuffer> result = DataBufferUtils.split(source, delimiter, false);
StepVerifier.create(result)
.consumeNextWith(stringConsumer("--"))
.consumeNextWith(stringConsumer("foo--"))
.consumeNextWith(stringConsumer("bar--"))
.consumeNextWith(stringConsumer("baz--"))
.verifyComplete();
}
@Test
public void splitMultipleDelimiters() {
Mono<DataBuffer> source =
deferStringBuffer("foo␤bar␍␤baz␤");
byte[][] delimiters = new byte[][]{
"".getBytes(StandardCharsets.UTF_8),
"␍␤".getBytes(StandardCharsets.UTF_8)
};
Flux<DataBuffer> result = DataBufferUtils.split(source, delimiters, false);
StepVerifier.create(result)
.consumeNextWith(stringConsumer("foo␤"))
.consumeNextWith(stringConsumer("bar␍␤"))
.consumeNextWith(stringConsumer("baz␤"))
.verifyComplete();
}
@Test
public void splitErrors() {
Flux<DataBuffer> source = Flux.concat(
deferStringBuffer("foo--"),
deferStringBuffer("bar--"),
Mono.error(new RuntimeException())
);
byte[] delimiter = "--".getBytes(StandardCharsets.UTF_8);
Flux<DataBuffer> result = DataBufferUtils.split(source, delimiter);
StepVerifier.create(result)
.consumeNextWith(stringConsumer("foo"))
.consumeNextWith(stringConsumer("bar"))
.expectError(RuntimeException.class)
.verify();
}
@Test
public void splitCanceled() {
Flux<DataBuffer> source = Flux.concat(
deferStringBuffer("foo--"),
deferStringBuffer("bar--"),
deferStringBuffer("baz")
);
byte[] delimiter = "--".getBytes(StandardCharsets.UTF_8);
Flux<DataBuffer> result = DataBufferUtils.split(source, delimiter);
StepVerifier.create(result)
.thenCancel()
.verify();
}
@Test
public void splitWithoutDemand() {
Flux<DataBuffer> source = Flux.concat(
deferStringBuffer("foo--"),
deferStringBuffer("bar--")
);
byte[] delimiter = "--".getBytes(StandardCharsets.UTF_8);
Flux<DataBuffer> result = DataBufferUtils.split(source, delimiter);
BaseSubscriber<DataBuffer> subscriber = new ZeroDemandSubscriber();
result.subscribe(subscriber);
subscriber.cancel();
}
@Test
public void splitAcrossBuffer() {
Flux<DataBuffer> source = Flux.concat(
deferStringBuffer("foo-"),
deferStringBuffer("-bar-"),
deferStringBuffer("-baz"));
byte[] delimiter = "--".getBytes(StandardCharsets.UTF_8);
Flux<DataBuffer> result = DataBufferUtils.split(source, delimiter);
StepVerifier.create(result)
.consumeNextWith(stringConsumer("foo"))
.consumeNextWith(stringConsumer("bar"))
.consumeNextWith(stringConsumer("baz"))
.verifyComplete();
}
private static class ZeroDemandSubscriber extends BaseSubscriber<DataBuffer> {