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
AcceptHeaderLocaleResolver ignores defaultLocale when Accept-Language header is present but blank #36512
AcceptHeaderLocaleResolver correctly returns defaultLocale when the Accept-Language header is absent (null), but ignores it when the header is present with a blank value (""), falling back to Locale.getDefault() (JVM system locale) instead.
This check only guards against null. A blank "" header value passes through, hits request.getLocale() which delegates to the JVM default locale — ignoring the configured defaultLocale entirely.
Expected Behaviour
A blank Accept-Language header value represents the same intent as an absent header — "no language preference". Both should return defaultLocale when configured.
Steps to Reproduce
AcceptHeaderLocaleResolverresolver = newAcceptHeaderLocaleResolver();
resolver.setDefaultLocale(Locale.forLanguageTag("az"));
resolver.setSupportedLocales(List.of(Locale.forLanguageTag("az")));
MockHttpServletRequestrequest = newMockHttpServletRequest();
request.addHeader("Accept-Language", ""); // blank, not nullLocaleresult = resolver.resolveLocale(request);
// actual: en (JVM default)// expected: az (configured defaultLocale)
Reproducible via curl: curl --header 'Accept-Language;' sends the header with an empty string value, which Tomcat parses as accept-language = "" (confirmed via MimeHeaders debug logging)
JVM default locale affects result — behaviour differs across environments
Activity
bclozel commentedon Mar 22, 2026
Superseded by #36513