Merge branch '5.1.x'
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2018 the original author or authors.
|
||||
* Copyright 2002-2019 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.
|
||||
@@ -199,7 +199,7 @@ public class MockHttpServletRequest implements HttpServletRequest {
|
||||
private String remoteHost = DEFAULT_REMOTE_HOST;
|
||||
|
||||
/** List of locales in descending order. */
|
||||
private final List<Locale> locales = new LinkedList<>();
|
||||
private final LinkedList<Locale> locales = new LinkedList<>();
|
||||
|
||||
private boolean secure = false;
|
||||
|
||||
@@ -779,7 +779,7 @@ public class MockHttpServletRequest implements HttpServletRequest {
|
||||
*/
|
||||
public void addPreferredLocale(Locale locale) {
|
||||
Assert.notNull(locale, "Locale must not be null");
|
||||
this.locales.add(0, locale);
|
||||
this.locales.addFirst(locale);
|
||||
updateAcceptLanguageHeader();
|
||||
}
|
||||
|
||||
@@ -817,7 +817,7 @@ public class MockHttpServletRequest implements HttpServletRequest {
|
||||
*/
|
||||
@Override
|
||||
public Locale getLocale() {
|
||||
return this.locales.get(0);
|
||||
return this.locales.getFirst();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1015,6 +1015,9 @@ public class MockHttpServletRequest implements HttpServletRequest {
|
||||
List<Locale> locales = headers.getAcceptLanguageAsLocales();
|
||||
this.locales.clear();
|
||||
this.locales.addAll(locales);
|
||||
if (this.locales.isEmpty()) {
|
||||
this.locales.add(Locale.ENGLISH);
|
||||
}
|
||||
}
|
||||
catch (IllegalArgumentException ex) {
|
||||
// Invalid Accept-Language format -> just store plain header
|
||||
|
||||
Reference in New Issue
Block a user