diff --git a/spring-web/src/main/java/org/springframework/web/server/i18n/AcceptHeaderLocaleContextResolver.java b/spring-web/src/main/java/org/springframework/web/server/i18n/AcceptHeaderLocaleContextResolver.java index 6b0f88f650b0..cde909cf1928 100644 --- a/spring-web/src/main/java/org/springframework/web/server/i18n/AcceptHeaderLocaleContextResolver.java +++ b/spring-web/src/main/java/org/springframework/web/server/i18n/AcceptHeaderLocaleContextResolver.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2018 the original author or authors. + * Copyright 2002-2020 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -39,6 +39,7 @@ * @author Sebastien Deleuze * @author Juergen Hoeller * @since 5.0 + * @see HttpHeaders#getAcceptLanguageAsLocales() */ public class AcceptHeaderLocaleContextResolver implements LocaleContextResolver { @@ -76,6 +77,7 @@ public void setDefaultLocale(@Nullable Locale defaultLocale) { /** * The configured default locale, if any. + *

This method may be overridden in subclasses. */ @Nullable public Locale getDefaultLocale() { @@ -98,7 +100,7 @@ public LocaleContext resolveLocaleContext(ServerWebExchange exchange) { @Nullable private Locale resolveSupportedLocale(@Nullable List requestLocales) { if (CollectionUtils.isEmpty(requestLocales)) { - return this.defaultLocale; // may be null + return getDefaultLocale(); // may be null } List supportedLocales = getSupportedLocales(); if (supportedLocales.isEmpty()) { @@ -128,7 +130,8 @@ else if (languageMatch == null) { return languageMatch; } - return (this.defaultLocale != null ? this.defaultLocale : requestLocales.get(0)); + Locale defaultLocale = getDefaultLocale(); + return (defaultLocale != null ? defaultLocale : requestLocales.get(0)); } @Override 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 8948c5be8bc4..4fcf4a56cd97 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 @@ -1,5 +1,5 @@ /* - * Copyright 2002-2018 the original author or authors. + * Copyright 2002-2020 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -83,6 +83,7 @@ public void setDefaultLocale(@Nullable Locale defaultLocale) { /** * The configured default locale, if any. + *

This method may be overridden in subclasses. * @since 4.3 */ @Nullable