提交 1bdbc7bd 编写于 作者: B Brian Clozel

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
上级 bff2d2cc
......@@ -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) {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册