Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix default StringHttpMessageConverter #43640

Conversation

sonjih00n
Copy link

image
https://docs.spring.io/spring-boot/appendix/application-properties/index.html#application-properties.server.server.servlet.encoding.charset

Since the default value of server.servlet.encoding.charset is UTF-8, StringHttpMessageConverter with UTF-8 encoding is automatically created by the code below.

@Bean
@ConditionalOnMissingBean
public StringHttpMessageConverter stringHttpMessageConverter(Environment environment) {
Encoding encoding = Binder.get(environment).bindOrCreate("server.servlet.encoding", Encoding.class);
StringHttpMessageConverter converter = new StringHttpMessageConverter(encoding.getCharset());
converter.setWriteAcceptCharset(false);
return converter;
}

Therefore, HttpMessageConverters has two StringHttpMessageConverter as shown below.
image

So, StringHttpMessageConverter with ISO-8859-1 encoding is not used.
(Especially because the default value of server.servlet.encoding.charset is UTF-8)

Even if the developer sets ISO-8859-1 encoding according to the servlet default specification, There are two StringHttpMessageConverter using ISO-8859-1 encoding as shown below.

server.servlet.encoding.charset=ISO-8859-1

image
So, if there is an additional StringHttpMessageConverter, I would like to change it to not add the default StringHttpMessageConverter.

@pivotal-cla
Copy link

@sonjih00n Please sign the Contributor License Agreement!

Click here to manually synchronize the status of this Pull Request.

See the FAQ for frequently asked questions.

@pivotal-cla
Copy link

@sonjih00n Thank you for signing the Contributor License Agreement!

@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged label Dec 31, 2024
@bclozel
Copy link
Member

bclozel commented Jan 2, 2025

Build is failing. Please run the build before submitting PRs.
I think this is a duplicate of #21374 anyway - Spring Framework configures the default instance and Spring Boot contributes an additional one. While this might not be useful for the server-side case, message converters can be used in clients as well.

I'm declining this change as a result.

@bclozel bclozel closed this Jan 2, 2025
@bclozel bclozel added status: declined A suggestion or change that we don't feel we should currently apply and removed status: waiting-for-triage An issue we've not yet triaged labels Jan 2, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status: declined A suggestion or change that we don't feel we should currently apply
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants