You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
CharacterEncodingFilter should avoid overhead of setCharacterEncoding(String) #37753
When the CharacterEncodingFilter is configured, such as in a typical Spring Boot WebMVC application running on embedded Tomcat, on every request, CharacterEncodingFilter calls request.setCharacterEncoding(String). With Boot's defaults the request encoding is forced, so this happens even when the request already declares a charset. On Tomcat 11 that call resolves the name again each time: it lowercases it (allocating a new string), then looks it up in a ConcurrentHashMap. Servlet 6.1 added setCharacterEncoding(Charset), which Tomcat 11 implements without any lookup.
CharacterEncodingFilter.doFilterInternal
RequestFacade.setCharacterEncoding(String)
Request.setCharacterEncoding(String)
CharsetHolder.getInstance(String)
B2CConverter.getCharset(String)
String.toLowerCase(Locale.ENGLISH) "UTF-8" -> new String "utf-8"
CharsetCache.getCharset(String)
String.toLowerCase(Locale.ENGLISH) (already lower case, no copy)
ConcurrentHashMap.get hashes and compares the new string
The two Tomcat 11.0.29 Request methods differ only in that lookup:
Activity
Apply pre-resolved encoding through Servlet 6.1 setCharacterEncoding(…