Skip to content

Refactor how hints (like JsonView) are passed to codecs [SPR-14557] #19125

Closed
@spring-projects-issues

Description

@spring-projects-issues

Sébastien Deleuze opened SPR-14557 and commented

We need to define and standardize how context informations (like annotations for @JsonView) is passed to the codecs. In 5.0 M1, we temporarily use ResolvableType#getSource() but that does not work for wrapped return values like Mono<Foo> since the ResolvableType is not created from the MethodParameter + this is hardcoded and specific.

The original idea was to deal with that in a more flexible and maintainable way by using the Object... hints parameter of Encoder and Decoder. If we chose to go that way:

  • HttpMessageWriter and HttpMessageReader API will have to be updated to pass this Object... hints parameter
  • We should specify what should be in the Object parameter, or even perhaps use a more specific type like CodecContext ...
  • We should implement a way to provide this context in a configurable way, maybe with a mechanism similar to RequestBodyAdvice / ResponseBodyAdvice.

The mechanism should allow to pass additional informations needed for serializing / deserializing without wrapping the information like in Spring MVC MappingJacksonValue to provide a more powerful, flexible and maintainable mechanism.

I plan to provide a PR and will request feedbacks and reviews based on that.


Affects: 5.0 M1

Issue Links:

Metadata

Metadata

Assignees

Labels

in: webIssues in web modules (web, webmvc, webflux, websocket)type: taskA general task

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions