Skip to content

Commit b6c32d1

Browse files
committed
Update AcceptHeaderLocaleResolver to extend AbstractLocaleResolver
This commit updates AcceptHeaderLocaleResolver to extend AbstractLocaleResolver, which allows the removal of defaultLocale managing code in AcceptHeaderLocaleResolver.
1 parent 279f964 commit b6c32d1

File tree

1 file changed

+3
-29
lines changed

1 file changed

+3
-29
lines changed

spring-webmvc/src/main/java/org/springframework/web/servlet/i18n/AcceptHeaderLocaleResolver.java

Lines changed: 3 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2021 the original author or authors.
2+
* Copyright 2002-2022 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -33,21 +33,18 @@
3333
* specified in the "accept-language" header of the HTTP request (that is,
3434
* the locale sent by the client browser, normally that of the client's OS).
3535
*
36-
* <p>Note: Does not support {@code setLocale}, since the accept header
36+
* <p>Note: Does not support {@code setLocale}, since the "accept-header"
3737
* can only be changed through changing the client's locale settings.
3838
*
3939
* @author Juergen Hoeller
4040
* @author Rossen Stoyanchev
4141
* @since 27.02.2003
4242
* @see jakarta.servlet.http.HttpServletRequest#getLocale()
4343
*/
44-
public class AcceptHeaderLocaleResolver implements LocaleResolver {
44+
public class AcceptHeaderLocaleResolver extends AbstractLocaleResolver {
4545

4646
private final List<Locale> supportedLocales = new ArrayList<>(4);
4747

48-
@Nullable
49-
private Locale defaultLocale;
50-
5148

5249
/**
5350
* Configure supported locales to check against the requested locales
@@ -69,29 +66,6 @@ public List<Locale> getSupportedLocales() {
6966
return this.supportedLocales;
7067
}
7168

72-
/**
73-
* Configure a fixed default locale to fall back on if the request does not
74-
* have an "Accept-Language" header.
75-
* <p>By default this is not set in which case when there is no "Accept-Language"
76-
* header, the default locale for the server is used as defined in
77-
* {@link HttpServletRequest#getLocale()}.
78-
* @param defaultLocale the default locale to use
79-
* @since 4.3
80-
*/
81-
public void setDefaultLocale(@Nullable Locale defaultLocale) {
82-
this.defaultLocale = defaultLocale;
83-
}
84-
85-
/**
86-
* The configured default locale, if any.
87-
* <p>This method may be overridden in subclasses.
88-
* @since 4.3
89-
*/
90-
@Nullable
91-
public Locale getDefaultLocale() {
92-
return this.defaultLocale;
93-
}
94-
9569

9670
@Override
9771
public Locale resolveLocale(HttpServletRequest request) {

0 commit comments

Comments
 (0)