-
Notifications
You must be signed in to change notification settings - Fork 38.5k
Revise CookieLocaleResolver
to use ResponseCookie
#28779
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
Revise CookieLocaleResolver
to use ResponseCookie
#28779
Conversation
At present, creating CookieLocaleResolver with custom cookie name requires creating an instance using the default constructor and then using setter to configure the desired cookie name. This commit introduces CookieLocaleResolver constructor that accepts cookie name thus allowing for a simpler creation of an instance with the desired cookie name.
At present, CookieLocaleResolver extends CookieGenerator instead of AbstractLocale(Context)Resolver like other LocaleResolver implementations. This means it duplicates some common aspects of LocaleResolver hierarchy while also exposing some CookieGenerator operations, such as #addCookie and #removeCookie. Additionally, CookieGenerator's support for writing cookies is based on Servlet support which at current baseline doesn't support SameSite directive. This commit refactors CookieLocaleResolver to make it extend AbstractLocaleContextResolver and also replaces CookieGenerator's cookie writing support with newer and more capable ResponseCookie.
spring-webmvc/src/test/java/org/springframework/web/servlet/i18n/LocaleResolverTests.java
Show resolved
Hide resolved
CookieLocaleResolver
CookieLocaleResolver
to use ResponseCookie
At present, CookieLocaleResolver extends CookieGenerator instead of AbstractLocale(Context)Resolver like other LocaleResolver implementations. This means it duplicates some common aspects of LocaleResolver hierarchy while also exposing some CookieGenerator operations, such as #addCookie and #removeCookie. Additionally, CookieGenerator's support for writing cookies is based on Servlet support which at current baseline doesn't support SameSite directive. This commit refactors CookieLocaleResolver to make it extend AbstractLocaleContextResolver and also replaces CookieGenerator's cookie writing support with newer and more capable ResponseCookie. Simplify creation of CookieLocaleResolver with custom cookie name This commit introduces CookieLocaleResolver constructor that accepts cookie name thus allowing for a simpler creation of an instance with the desired cookie name. See gh-28779
I've also added some improvements in |
This commit deprecates CookieGenerator in favor of the more modern alternative, ResponseCookie. See gh-28870
It seems that introducing |
@sabomichal, this issue was closed almost 2 years ago. If you believe you have encountered a bug or something worth discussing, please create a new issue. |
This PR provides two commits that improve
CookieLocaleResolver
, as a follow-up on #27609:CookieLocaleResolver
with custom cookie nameAt present, creating
CookieLocaleResolver
with custom cookie name requires creating an instance using the default constructor and then using setter to configure the desired cookie name.This commit introduces
CookieLocaleResolver
constructor that accepts cookie name thus allowing for a simpler creation of an instance with the desired cookie name.CookieLocaleResolver
At present,
CookieLocaleResolver
extendsCookieGenerator
instead ofAbstractLocale(Context)Resolver
like otherLocaleResolver
implementations. This means it duplicates some common aspects ofLocaleResolver
hierarchy while also exposing someCookieGenerator
operations, such as#addCookie
and#removeCookie
.Additionally,
CookieGenerator
's support for writing cookies is based on Servlet support which at current baseline doesn't support SameSite directive.This commit refactors
CookieLocaleResolver
to make it extendAbstractLocaleContextResolver
and also replacesCookieGenerator
's cookie writing support with newer and more capableResponseCookie
.