Affects: 6.0.11


As reported previously in #26406, WebFlux does not support MappingJacksonValue<T> in non-streaming Flux sequences. Before Spring 6, the reason for that was that AbstractJackson2Encoder collected the flux into a list which was then encoded in one go: https://github.com/spring-projects/spring-framework/blob/13b31c7976491b7500efc34e9080e862165a22ab/spring-web/src/main/java/org/springframework/http/codec/json/AbstractJackson2Encoder.java#L185-L189

However, since Spring 6, AbstractJackson2Encoder no longer collects, but encodes each item individually: https://github.com/spring-projects/spring-framework/blob/84045374744aee245d1ed717454cb91e5d1c1ad3/spring-web/src/main/java/org/springframework/http/codec/json/AbstractJackson2Encoder.java#L187-L214


In my application, I need MappingJacksonValue and I'm encoding potentially very large sequences, where collecting them all into a list before wrapping them into MappingJacksonValue can cause memory issues.

Could we revisit this issue and maybe now get support for Flux<MappingJacksonValue<T>> with Spring 6?

Comment From: sdeleuze

The implementation has indeed changed and we invoke encodeStreamingValue for each element, but some information specified at MappingJacksonValue level like the serialization/json view are used when creating the ObjectWriter for the whole sequence of values, not per value. As a consequence, I think the team decision shared @poutsma still stands.