Skip to content

Encoding of flux data is incorrect [SPR-14586] #19155

@spring-projects-issues

Description

@spring-projects-issues

Athul opened SPR-14586 and commented

The response from spring-reactive-web controller given an invalid JSON data.

Example :
If the return value of a controller is Flux<Student> and assume there are four items the output is in the following format

[{"age":1,"name":"Tom"},{"age":2,"name":"Tom"}{"age":3,"name":"Tom"}{"age":4,"name":"Tom"},,]

The ordering of the data and the delimiter is getting lost while encoding the data from Flux<Student> to Flux<DataBuffer>.

I think the root cause of the issue is org.springframework.http.codec.json.Jackson2JsonEncoder.encode() has a particular step where Data and Delimiter are merged to a single flux. However currently it is using flatMap which leads to loosing of order. Instead if concatMap was used the order between data and delimiter would have been retained.


Affects: 5.0 M1

Referenced from: commits 417a9d4

Metadata

Metadata

Assignees

Labels

in: webIssues in web modules (web, webmvc, webflux, websocket)type: bugA general bug

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions