Customization for ObjectReader and ObjectWriter #28401
Closed
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
We are finding some needs to customize the ObjectReader and ObjectWriter for Jackson serialization and deserialization, while leveraging as much default behavior as possible for both our web services running in webflux and webmvc.
After doing some investigation, it looks like AbstractJackson2Encoder already provided a customize method: https://github.com/paychex/spring-framework/blob/main/spring-web/src/main/java/org/springframework/http/codec/json/AbstractJackson2Encoder.java#L315
There was however no consistency to be able to do this with the ObjectReader in the AbstractJackson2Decoder or on the webmvc side, as neither the ObjectWriter or ObjectReader had customization methods in AbstractJackson2HttpMessageConverter. This PR is for bringing the consistency so that we can now customize both for both webflux and webmvc.
This PR goes one step further as well on AbstractJackson2Decoder and AbstractJackson2Encoder to allow the customization as well from the reactive flow that will allow the ability to get contextual information from the current reactive flow for the customization which is another need we have.