diff --git a/spring-web/src/main/java/org/springframework/http/codec/json/JsonObjectDecoder.java b/spring-web/src/main/java/org/springframework/http/codec/json/JsonObjectDecoder.java index 93f6f47599..e90db76855 100644 --- a/spring-web/src/main/java/org/springframework/http/codec/json/JsonObjectDecoder.java +++ b/spring-web/src/main/java/org/springframework/http/codec/json/JsonObjectDecoder.java @@ -212,9 +212,6 @@ class JsonObjectDecoder extends AbstractDecoder { } } - if (this.input.readableBytes() == 0) { - this.index = 0; - } return Flux.fromIterable(chunks); } diff --git a/spring-web/src/test/java/org/springframework/http/codec/json/JsonObjectDecoderTests.java b/spring-web/src/test/java/org/springframework/http/codec/json/JsonObjectDecoderTests.java index 24f26e1f20..375da5260f 100644 --- a/spring-web/src/test/java/org/springframework/http/codec/json/JsonObjectDecoderTests.java +++ b/spring-web/src/test/java/org/springframework/http/codec/json/JsonObjectDecoderTests.java @@ -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(); }