Make StringDecoder use DataBufferUtils.split
* Added DataBufferUtils.split variant that takes multiple delimiters as argument (instead of 1). * Use this new split() variant from within StringDecoder, replacing its inefficient algorithm with the Knuth-Morris-Pratt algorithm.
This commit is contained in:
@@ -820,6 +820,25 @@ public class DataBufferUtilsTests extends AbstractDataBufferAllocatingTestCase {
|
||||
.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(
|
||||
|
||||
Reference in New Issue
Block a user