Skip to content

Commit 5383520

Browse files
committed
Sync changes in MockHttpServletRequest to spring-web test fixture
1 parent 0b5a9ea commit 5383520

1 file changed

Lines changed: 7 additions & 6 deletions

File tree

spring-web/src/testFixtures/java/org/springframework/web/testfixture/servlet/MockHttpServletRequest.java

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -222,7 +222,7 @@ public class MockHttpServletRequest implements HttpServletRequest {
222222

223223
private @Nullable String authType;
224224

225-
private @Nullable Cookie[] cookies;
225+
private Cookie @Nullable [] cookies;
226226

227227
private final Map<String, HeaderValueHolder> headers = new LinkedCaseInsensitiveMap<>();
228228

@@ -392,7 +392,8 @@ public void setCharacterEncoding(@Nullable String characterEncoding) {
392392
private void updateContentTypeHeader() {
393393
if (StringUtils.hasLength(this.contentType)) {
394394
String value = this.contentType;
395-
if (StringUtils.hasLength(this.characterEncoding) && !this.contentType.toLowerCase().contains(CHARSET_PREFIX)) {
395+
if (StringUtils.hasLength(this.characterEncoding) &&
396+
!this.contentType.toLowerCase(Locale.ROOT).contains(CHARSET_PREFIX)) {
396397
value += ';' + CHARSET_PREFIX + this.characterEncoding;
397398
}
398399
doAddHeaderValue(HttpHeaders.CONTENT_TYPE, value, true);
@@ -468,7 +469,7 @@ public void setContentType(@Nullable String contentType) {
468469
}
469470
catch (IllegalArgumentException ex) {
470471
// Try to get charset value anyway
471-
contentType = contentType.toLowerCase();
472+
contentType = contentType.toLowerCase(Locale.ROOT);
472473
int charsetIndex = contentType.indexOf(CHARSET_PREFIX);
473474
if (charsetIndex != -1) {
474475
this.characterEncoding = contentType.substring(charsetIndex + CHARSET_PREFIX.length());
@@ -616,7 +617,7 @@ public Enumeration<String> getParameterNames() {
616617
}
617618

618619
@Override
619-
public @Nullable String[] getParameterValues(String name) {
620+
public String @Nullable [] getParameterValues(String name) {
620621
Assert.notNull(name, "Parameter name must not be null");
621622
return this.parameters.get(name);
622623
}
@@ -998,7 +999,7 @@ public void setAuthType(@Nullable String authType) {
998999
return this.authType;
9991000
}
10001001

1001-
public void setCookies(@Nullable Cookie... cookies) {
1002+
public void setCookies(Cookie @Nullable ... cookies) {
10021003
this.cookies = (ObjectUtils.isEmpty(cookies) ? null : cookies);
10031004
if (this.cookies == null) {
10041005
removeHeader(HttpHeaders.COOKIE);
@@ -1015,7 +1016,7 @@ private static String encodeCookies(Cookie... cookies) {
10151016
}
10161017

10171018
@Override
1018-
public @Nullable Cookie[] getCookies() {
1019+
public Cookie @Nullable [] getCookies() {
10191020
return this.cookies;
10201021
}
10211022

0 commit comments

Comments
 (0)