From 9a0eb8db28193c2306226bdef2d5af0c69050ef1 Mon Sep 17 00:00:00 2001 From: Vedran Pavic Date: Mon, 25 Oct 2021 09:11:53 +0200 Subject: [PATCH] Update AcceptHeaderLocaleResolver to extend AbstractLocaleResolver This commit updates AcceptHeaderLocaleResolver to extend AbstractLocaleResolver, which allows the removal of defaultLocale managing code in AcceptHeaderLocaleResolver. See gh-27609 --- .../i18n/AcceptHeaderLocaleResolver.java | 28 +------------------ 1 file changed, 1 insertion(+), 27 deletions(-) diff --git a/spring-webmvc/src/main/java/org/springframework/web/servlet/i18n/AcceptHeaderLocaleResolver.java b/spring-webmvc/src/main/java/org/springframework/web/servlet/i18n/AcceptHeaderLocaleResolver.java index 64f9a89a79..15e514f286 100644 --- a/spring-webmvc/src/main/java/org/springframework/web/servlet/i18n/AcceptHeaderLocaleResolver.java +++ b/spring-webmvc/src/main/java/org/springframework/web/servlet/i18n/AcceptHeaderLocaleResolver.java @@ -41,13 +41,10 @@ import org.springframework.web.servlet.LocaleResolver; * @since 27.02.2003 * @see jakarta.servlet.http.HttpServletRequest#getLocale() */ -public class AcceptHeaderLocaleResolver implements LocaleResolver { +public class AcceptHeaderLocaleResolver extends AbstractLocaleResolver { private final List supportedLocales = new ArrayList<>(4); - @Nullable - private Locale defaultLocale; - /** * Configure supported locales to check against the requested locales @@ -69,29 +66,6 @@ public class AcceptHeaderLocaleResolver implements LocaleResolver { return this.supportedLocales; } - /** - * Configure a fixed default locale to fall back on if the request does not - * have an "Accept-Language" header. - *

By default this is not set in which case when there is no "Accept-Language" - * header, the default locale for the server is used as defined in - * {@link HttpServletRequest#getLocale()}. - * @param defaultLocale the default locale to use - * @since 4.3 - */ - public void setDefaultLocale(@Nullable Locale defaultLocale) { - this.defaultLocale = defaultLocale; - } - - /** - * The configured default locale, if any. - *

This method may be overridden in subclasses. - * @since 4.3 - */ - @Nullable - public Locale getDefaultLocale() { - return this.defaultLocale; - } - @Override public Locale resolveLocale(HttpServletRequest request) {