Refactor AcceptHeaderLocaleResolver to implement LocaleContextResolver - #29239
Refactor AcceptHeaderLocaleResolver to implement LocaleContextResolver#29239vpavic wants to merge 3 commits into
Conversation
At present, AcceptHeaderLocaleResolver is the only LocaleResolver implementation that doesn't also implement LocaleContextResolver. This is also not aligned with WebFlux, where the entire resolver hierarchy works with LocaleContext. This commit updates AcceptHeaderLocaleResolver to implement LocaleContextResolver.
This commit deprecates AbstractLocaleResolver in favor of AbstractLocaleContextResolver.
This commit deprecates LocaleResolver and updates all references to use LocaleContextResolver instead.
|
While I see the point of the PR, I am not inclined to proceed with phasing out Point taken that WebFlux has full-scale |
This PR wraps up efforts to improve
org.springframework.web.servlet.LocaleResolverhierarchy started in:CookieLocaleResolverto useResponseCookie#28779The core change proposed here (first commit) is to refactor
AcceptHeaderLocaleResolverto implementLocaleContextResolver, which makes the all locale resolvers provided by Spring MVCLocaleContextResolverbased. It also aligns Spring MVC with Spring WebFlux, where all resolvers work withLocaleContextrather than plainLocale.The two subsequent commits are optional, but could be helpful as they prepare ground to simplifying
LocaleResolverhierarchy in the future:AbstractLocaleResolverin favor ofAbstractLocaleContextResolver, as nothing is usingAbstractLocaleResolverafter the first commitorg.springframework.web.servlet.LocaleResolverand reworks all the references to operate againstLocaleContextResolver- while technically a breaking change, this only impacts those with customLocaleResolverthat don't implementLocaleContextResolver