Fix JsonObjectDecoder with '[' starting chunk

Issue: SPR-15013
This commit is contained in:
Sebastien Deleuze 2016-12-14 14:38:19 +01:00
parent b70071fdda
commit 4021d239ab
2 changed files with 13 additions and 3 deletions

View File

@ -212,9 +212,6 @@ class JsonObjectDecoder extends AbstractDecoder<DataBuffer> {
}
}
if (this.input.readableBytes() == 0) {
this.index = 0;
}
return Flux.fromIterable(chunks);
}

View File

@ -106,6 +106,19 @@ public class JsonObjectDecoderTests extends AbstractDataBufferAllocatingTestCase
.expectNext("{\"foo\": \"baz\"}")
.expectComplete()
.verify();
// SPR-15013
source = Flux.just(stringBuffer("["), stringBuffer("{\"id\":1,\"name\":\"Robert\"}"),
stringBuffer(","), stringBuffer("{\"id\":2,\"name\":\"Raide\"}"),
stringBuffer(","), stringBuffer("{\"id\":3,\"name\":\"Ford\"}"),
stringBuffer("]"));
output = decoder.decode(source, null, null, Collections.emptyMap()).map(JsonObjectDecoderTests::toString);
StepVerifier.create(output)
.expectNext("{\"id\":1,\"name\":\"Robert\"}")
.expectNext("{\"id\":2,\"name\":\"Raide\"}")
.expectNext("{\"id\":3,\"name\":\"Ford\"}")
.expectComplete()
.verify();
}