Affects: All spring versions
Why does AbstractJackson2Encoder
have a method customizeWriter()
, but AbstractJackson2Decoder
does not have a similar method customizeReader()
.
If you look at the getObjectReader()
method at https://github.com/spring-projects/spring-framework/blob/main/spring-web/src/main/java/org/springframework/http/codec/json/AbstractJackson2Decoder.java#L205 and similarly, the getObjectWriter()
method at https://github.com/spring-projects/spring-framework/blob/main/spring-web/src/main/java/org/springframework/http/codec/json/AbstractJackson2Encoder.java#L297 , they are fairly similar, but createObjectReader()
seems to have a call to customizeWriter()
.
My understanding is possibly the difference between the get
and create
in the method names, but both of them essentially still call mapper.writerFor(...)
or mapper.readerFor(...)
type calls. Is there a specific reason why such a method is not available? Also any workarounds available to be able to customize the reader as part of the decode
flow.
Comment From: sbrannen
Is there a specific reason why such a method is not available?
I assume it was simply an oversight.
The encoder received the customizeWriter()
method when it was introduced in https://github.com/spring-projects/spring-framework/commit/f46520e6e8e70e59ad46bc31debdfd155cf943bc#diff-601bc27f8587c320cf4580d9df497ce519c5759ad68e1e39e396f37668fff4abR145-R148.
The decoder never received an analogous customizeReader()
method.
Also any workarounds available to be able to customize the reader as part of the
decode
flow.
I don't think there are currently any workarounds for this, but we will consider introducing customizeReader(...)
in AbstractJackson2Decoder
.
Comment From: rstoyanchev
The customizeWriter was needed for an uncommon need, to enforce a fixed PrettyPrinter for SSE output which has to write newlines in SSE format. Typically, you shouldn't need such request-specific customizations, and rather configure at the ObjectMapper level. Can you clarify what you're trying to use this for?
Comment From: spring-projects-issues
If you would like us to look at this issue, please provide the requested information. If the information is not provided within the next 7 days this issue will be closed.
Comment From: spring-projects-issues
Closing due to lack of requested feedback. If you would like us to look at this issue, please provide the requested information and we will re-open the issue.