Skip to content

Rework server.servlet.encoding properties to clarify when they apply #45394

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

Open
wilkinsona opened this issue May 8, 2025 · 0 comments
Open
Labels
status: pending-design-work Needs design work before any code can be developed theme: structure Issues related to the structure of the project and its code
Milestone

Comments

@wilkinsona
Copy link
Member

wilkinsona commented May 8, 2025

  • server.servlet.encoding.force, server.servlet.encoding.force-request, server.servlet.encoding.force-response
    • HttpEncodingAutoConfiguration applies them to auto-configured CharacterEncodingFilter
      • affects any servlet web app, not just an embedded web server
  • server.servlet.encoding.charset
    • HttpMessageConvertersAutoConfiguration applies it to auto-configured StringHttpMessageConverter
      • affects reading or writing of Strings during blocking HTTP exchanges (Spring MVC, RestTemplate, RestClient)
    • HttpEncodingAutoConfiguration applies it to auto-configured CharacterEncodingFilter
      • affects any servlet web app, not just an embedded web server
  • server.servlet.encoding.mapping
    • HttpEncodingAutoConfiguration applies it to ConfigurableServletWebServerFactory
      • affects servlet web apps using an embedded web server

Prior to #18827, properties were all named spring.http.encoding.*..
I think we need to move to somewhere between the two extremes, perhaps the following:

spring.servlet.encoding.charset
spring.servlet.encoding.force
spring.servlet.encoding.force-request
spring.servlet.encoding.force-response

spring.http.converters.string-encoding-charset

server.servlet.encoding.mapping

I'm unsure about both spring.servlet.encoding.charset and spring.http.converters.string-encoding-charset. The former should be applied to the auto-configured CharacterEncodingFilter that applies to all servlet web apps. The latter would be applied to the auto-configured StringHttpMessageConverter that applies to any blocking HTTP exchange using Spring MVC, RestTemplate, or RestClient. Having two properties that will have the same value the vast majority of the time is not ideal.

@wilkinsona wilkinsona added this to the 4.0.x milestone May 8, 2025
@wilkinsona wilkinsona added status: pending-design-work Needs design work before any code can be developed theme: structure Issues related to the structure of the project and its code labels May 8, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status: pending-design-work Needs design work before any code can be developed theme: structure Issues related to the structure of the project and its code
Projects
None yet
Development

No branches or pull requests

1 participant