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
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.
The text was updated successfully, but these errors were encountered:
kerkhofsd
changed the title
AwsProxyHttpServletRequest#getLocale incorrect for locales with country part
AwsProxyHttpServletRequest#getLocale incorrect for locales with country subtag
Apr 14, 2023
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 theLocale
from theAccept-Language
header in theLocaleContextHolder
.This
AcceptHeaderLocaleResolver
usesHttpServletRequest#getLocale()
to retrieve the locale from the request. TheHttpServletRequest
implementation is provided by theaws-serverless-java-container
asAwsProxyHttpServletRequest
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 aLocale
from theAccept-Language
header using the single valueLocale
constructor.For values containing a country tag (e.g.
en-GB
), an incorrect locale is constructed withen-gb
as language code and no country code.Suggested solution
Use
Locale#forLanguageTag
to construct the locale from theAccept-Language
header value.Additional info
On first sight I would say that
AwsHttpApiV2ProxyHttpServletRequest
has the same problem.The text was updated successfully, but these errors were encountered: