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:
@@ -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("foobar␍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> {
|
||||
|
||||
|
||||
Reference in New Issue
Block a user