spring-projects / spring-projects/spring-framework

Provide MediaType to AbstractJacksonHttpMessageConverter.customizeReader

Open
#37,094 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

status: waiting-for-triage
Dominant language
Java
Stars
60.2k
Forks
38.8k
Avg merge
5d 2h
Merged PRs (30d)
27

Description

I am implementing a CSV message converter by extending AbstractJacksonHttpMessageConverter.

While customizerWriter supplies the target MediaType, customizeReader does not supply the source MediaType.

As a result, I cannot check the "header" parameter to decide the value for CsvSchema.withUseHeader.

A new extension point could be added without breaking anything:

protected ObjectReader customizeReader(
        ObjectReader reader, JavaType javaType, @Nullable MediaType contentType) {

    return customizeReader(reader, javaType);
}

This could also be of general use for other formats, as media types such as application/x-my-thing+json are commonly used, and knowing the base type may be useful in configuring a reader.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start at AbstractJacksonHttpMessageConverter and compare customizeReader with customizeWriter, then inspect the surrounding message-converter tests. Verify how MediaType is passed during reader customization and preserve the existing overload behavior; done means CSV and other media-type-aware readers can access the source content type without breaking existing subclasses.

Written by the indexing model from the issue text.

Assessment

Tech stack
java
Domain
backend
Issue type
Feature
Difficulty
3/5
Estimated time
1-2 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
62/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.