Previously, in spring 5.1, org.springframework.core.codec.Encoder and Decoder implementations could take advantage of the reactor subscriber Context, since all methods returned a Mono or Flux.
In spring 5.2, the following synchronous methods were added (as part of #22782):
- in
Encoder... DataBuffer encodeValue(T value, DataBufferFactory bufferFactory, ResolvableType valueType, MimeType mimeType, Map<String, Object> hints)
- in
Decoder... T decode(DataBuffer buffer, ResolvableType targetType, MimeType mimeType, Map<String, Object> hints)
These new methods are called instead of the older methods in various places. E.g. EncoderHttpMessageWriter.write calls encoder.encodeValue in spring 5.2, where it previously called encoder.encode in spring 5.1. See also this comment.
These new methods do not provide access to the subscriber Context (since they don't return a Mono/Flux). And there is also no way to force all callers to go back to the previous behavior of calling the old methods which do provide access to the Context.
Therefore, previous Encoder/Decoder implementations that utilized the subscriber Context are now broken in spring 5.2.
I'd like for the subscriber Context to be available in all of the encode*/decode* methods in an Encoder/Decoder.
Perhaps the Context could be added as a hint? Or another default method added that provides the Context as an additional argument?
Previously, in spring 5.1,
org.springframework.core.codec.EncoderandDecoderimplementations could take advantage of the reactor subscriberContext, since all methods returned aMonoorFlux.In spring 5.2, the following synchronous methods were added (as part of #22782):
Encoder...DataBuffer encodeValue(T value, DataBufferFactory bufferFactory, ResolvableType valueType, MimeType mimeType, Map<String, Object> hints)Decoder...T decode(DataBuffer buffer, ResolvableType targetType, MimeType mimeType, Map<String, Object> hints)These new methods are called instead of the older methods in various places. E.g.
EncoderHttpMessageWriter.writecallsencoder.encodeValuein spring 5.2, where it previously calledencoder.encodein spring 5.1. See also this comment.These new methods do not provide access to the subscriber
Context(since they don't return aMono/Flux). And there is also no way to force all callers to go back to the previous behavior of calling the old methods which do provide access to theContext.Therefore, previous Encoder/Decoder implementations that utilized the subscriber
Contextare now broken in spring 5.2.I'd like for the subscriber Context to be available in all of the encode*/decode* methods in an Encoder/Decoder.
Perhaps the Context could be added as a hint? Or another default method added that provides the Context as an additional argument?