-
Notifications
You must be signed in to change notification settings - Fork 571
Description
Serverless Java Container version: 1.9.1
Implementations: Spring Boot 2
Framework version: SpringBoot 2.7.10
Frontend service: REST API
Deployment method: Serverless Framework
Scenario
We are relying on Spring's AcceptHeaderLocaleResolver to store the Locale from the Accept-Language header in the LocaleContextHolder.
This AcceptHeaderLocaleResolver uses HttpServletRequest#getLocale() to retrieve the locale from the request. The HttpServletRequest implementation is provided by the aws-serverless-java-container as AwsProxyHttpServletRequest
Expected behavior
AwsProxyHttpServletRequest#getLocale() provides a correct locale, both for locales with (e.g. en-GB) and without (e.g. en) a country tag.
Actual behavior
AwsProxyHttpServletRequest#getLocale() constructs a Locale from the Accept-Language header using the single value Locale constructor.
For values containing a country tag (e.g. en-GB), an incorrect locale is constructed with en-gb as language code and no country code.
Suggested solution
Use Locale#forLanguageTag to construct the locale from the Accept-Language header value.
Additional info
On first sight I would say that AwsHttpApiV2ProxyHttpServletRequest has the same problem.