Optimize for Flux to/from Mono conversions
This commit optimizes Flux <-> Mono conversions in our codebase by avoiding to hide that conversion from Reactor. This tries to keep conversions sequentially so that they can be detected by Reactor and optimized. In Spring WebFlux, this means keeping the conversions at the edges of a method implementation (right when getting an input parameter, and before returning it as a result). If those conversions are made between other operators, Reactor might not be able to detect those conversions and optimize them. Issue: SPR-17203
This commit is contained in:
parent
bff2d2cc85
commit
1bdbc7bdef
|
@ -116,8 +116,8 @@ public abstract class AbstractJackson2Encoder extends Jackson2CodecSupport imple
|
|||
JsonEncoding encoding = getJsonEncoding(mimeType);
|
||||
|
||||
if (inputStream instanceof Mono) {
|
||||
return Flux.from(inputStream).map(value ->
|
||||
encodeValue(value, mimeType, bufferFactory, elementType, hints, encoding));
|
||||
return Mono.from(inputStream).map(value ->
|
||||
encodeValue(value, mimeType, bufferFactory, elementType, hints, encoding)).flux();
|
||||
}
|
||||
|
||||
for (MediaType streamingMediaType : this.streamingMediaTypes) {
|
||||
|
|
Loading…
Reference in New Issue