Ensure StringDecoder supports multiline delimiters

This commit makes sure the StringDecoder supports stripping off
multi-line delimiters, such as \r\n. Specifically, we ensure that the
delimiter is stripped from the joined buffer.

Closes gh-26511
This commit is contained in:
Arjen Poutsma
2021-02-08 15:40:47 +01:00
parent 6c22f7ef5e
commit c09b2513e0
2 changed files with 25 additions and 6 deletions

View File

@@ -125,10 +125,10 @@ class StringDecoderTests extends AbstractDecoderTests<StringDecoder> {
);
testDecode(input, String.class, step -> step
.expectNext("")
.expectNext("").as("1st")
.expectNext("abc")
.expectNext("defghi")
.expectNext("")
.expectNext("").as("2nd")
.expectNext("jklmno")
.expectNext("pqr")
.expectNext("stuvwxyz")
@@ -136,6 +136,21 @@ class StringDecoderTests extends AbstractDecoderTests<StringDecoder> {
.verify());
}
@Test
void decodeNewlinesAcrossBuffers() {
Flux<DataBuffer> input = Flux.just(
stringBuffer("\r"),
stringBuffer("\n"),
stringBuffer("xyz")
);
testDecode(input, String.class, step -> step
.expectNext("")
.expectNext("xyz")
.expectComplete()
.verify());
}
@Test
void maxInMemoryLimit() {
Flux<DataBuffer> input = Flux.just(