spring-projects / spring-projects/spring-framework
Lack of symmetry for streaming media types in WebClient and on the server with MVC
Nobody has claimed this yet.
- Dominant language
- Java
- Stars
- 60.2k
- Forks
- 38.8k
- Avg merge
- 5d 2h
- Merged PRs (30d)
- 27
Description
JacksonJsonDecoder has a list of mime types including APPLICATION_NDJSON.
But the ReactiveTypeHandler (used on the server side) has WILDCARD_SUBTYPE_SUFFIXED_BY_NDJSON so it supports a wider range of media types. Ideally they would be the same.
A workaround is to just use application/x-ndjson on the server. Or to replace the default JSON decoder on the client side:
@BeforeEach
void setUp(@Autowired WebClient.Builder builder, @LocalServerPort int port) {
this.rest = builder.codecs(config -> {
MimeType[] mimeTypes = new MimeType[] {
MediaType.APPLICATION_JSON,
new MediaType("application", "*+json"),
MediaType.APPLICATION_NDJSON,
MediaType.valueOf("application/*+x-ndjson")
};
JacksonJsonDecoder decoder = new JacksonJsonDecoder(JsonMapper.builder(), mimeTypes);
config.defaultCodecs().jacksonJsonDecoder(decoder);
}).baseUrl("http://localhost:" + port).build();
}
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by comparing the supported media types in JacksonJsonDecoder with the WILDCARD_SUBTYPE_SUFFIXED_BY_NDJSON handling in ReactiveTypeHandler. Trace the existing WebClient and server-side MVC paths that use these classes, then check their related tests if present. Done means both sides accept the same relevant streaming JSON media types without requiring the workaround described in the issue.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java
- Domain
- api, backend
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Active
- Clarity
- Mostly clear
- Newbie friendliness
- 68/100