Fix JacksonJsonEncoder for streams with more than 2 elements
This commit is contained in:
parent
c1518c3fde
commit
7ed03d01c6
|
@ -83,7 +83,7 @@ public class JacksonJsonEncoder extends AbstractEncoder<Object> {
|
|||
Mono<DataBuffer> startArray =
|
||||
Mono.just(bufferFactory.wrap(START_ARRAY_BUFFER));
|
||||
Flux<DataBuffer> arraySeparators =
|
||||
Mono.just(bufferFactory.wrap(SEPARATOR_BUFFER)).repeat();
|
||||
Mono.fromSupplier(() -> bufferFactory.wrap(SEPARATOR_BUFFER)).repeat();
|
||||
Mono<DataBuffer> endArray =
|
||||
Mono.just(bufferFactory.wrap(END_ARRAY_BUFFER));
|
||||
|
||||
|
|
|
@ -52,7 +52,11 @@ public class JacksonJsonEncoderTests extends AbstractDataBufferAllocatingTestCas
|
|||
|
||||
@Test
|
||||
public void encode() {
|
||||
Flux<Pojo> source = Flux.just(new Pojo("foofoo", "barbar"), new Pojo("foofoofoo", "barbarbar"));
|
||||
Flux<Pojo> source = Flux.just(
|
||||
new Pojo("foo", "bar"),
|
||||
new Pojo("foofoo", "barbar"),
|
||||
new Pojo("foofoofoo", "barbarbar")
|
||||
);
|
||||
|
||||
ResolvableType type = ResolvableType.forClass(Pojo.class);
|
||||
Flux<DataBuffer> output =
|
||||
|
@ -62,11 +66,15 @@ public class JacksonJsonEncoderTests extends AbstractDataBufferAllocatingTestCas
|
|||
.subscribe(output)
|
||||
.assertComplete()
|
||||
.assertNoError()
|
||||
.assertValuesWith(stringConsumer("["),
|
||||
.assertValuesWith(
|
||||
stringConsumer("["),
|
||||
stringConsumer("{\"foo\":\"foo\",\"bar\":\"bar\"}"),
|
||||
stringConsumer(","),
|
||||
stringConsumer("{\"foo\":\"foofoo\",\"bar\":\"barbar\"}"),
|
||||
stringConsumer(","),
|
||||
stringConsumer("{\"foo\":\"foofoofoo\",\"bar\":\"barbarbar\"}"),
|
||||
stringConsumer("]"));
|
||||
stringConsumer("]")
|
||||
);
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
Loading…
Reference in New Issue