Skip to content

Commit 30287d7

Browse files
committed
Merge branch '7.0.x'
2 parents c26029c + 292959e commit 30287d7

2 files changed

Lines changed: 13 additions & 8 deletions

File tree

spring-test/src/main/java/org/springframework/mock/web/MockHttpServletRequest.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@
6666

6767
import org.springframework.http.HttpHeaders;
6868
import org.springframework.http.MediaType;
69+
import org.springframework.lang.Contract;
6970
import org.springframework.util.Assert;
7071
import org.springframework.util.LinkedCaseInsensitiveMap;
7172
import org.springframework.util.LinkedMultiValueMap;
@@ -1311,6 +1312,7 @@ public void setSession(HttpSession session) {
13111312
}
13121313

13131314
@Override
1315+
@Contract("true -> !null")
13141316
public @Nullable HttpSession getSession(boolean create) {
13151317
checkActive();
13161318
// Reset session if invalidated.
@@ -1325,7 +1327,7 @@ public void setSession(HttpSession session) {
13251327
}
13261328

13271329
@Override
1328-
public @Nullable HttpSession getSession() {
1330+
public HttpSession getSession() {
13291331
return getSession(true);
13301332
}
13311333

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

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@
6666

6767
import org.springframework.http.HttpHeaders;
6868
import org.springframework.http.MediaType;
69+
import org.springframework.lang.Contract;
6970
import org.springframework.util.Assert;
7071
import org.springframework.util.LinkedCaseInsensitiveMap;
7172
import org.springframework.util.LinkedMultiValueMap;
@@ -222,7 +223,7 @@ public class MockHttpServletRequest implements HttpServletRequest {
222223

223224
private @Nullable String authType;
224225

225-
private @Nullable Cookie[] cookies;
226+
private Cookie @Nullable [] cookies;
226227

227228
private final Map<String, HeaderValueHolder> headers = new LinkedCaseInsensitiveMap<>();
228229

@@ -392,7 +393,8 @@ public void setCharacterEncoding(@Nullable String characterEncoding) {
392393
private void updateContentTypeHeader() {
393394
if (StringUtils.hasLength(this.contentType)) {
394395
String value = this.contentType;
395-
if (StringUtils.hasLength(this.characterEncoding) && !this.contentType.toLowerCase().contains(CHARSET_PREFIX)) {
396+
if (StringUtils.hasLength(this.characterEncoding) &&
397+
!this.contentType.toLowerCase(Locale.ROOT).contains(CHARSET_PREFIX)) {
396398
value += ';' + CHARSET_PREFIX + this.characterEncoding;
397399
}
398400
doAddHeaderValue(HttpHeaders.CONTENT_TYPE, value, true);
@@ -468,7 +470,7 @@ public void setContentType(@Nullable String contentType) {
468470
}
469471
catch (IllegalArgumentException ex) {
470472
// Try to get charset value anyway
471-
contentType = contentType.toLowerCase();
473+
contentType = contentType.toLowerCase(Locale.ROOT);
472474
int charsetIndex = contentType.indexOf(CHARSET_PREFIX);
473475
if (charsetIndex != -1) {
474476
this.characterEncoding = contentType.substring(charsetIndex + CHARSET_PREFIX.length());
@@ -616,7 +618,7 @@ public Enumeration<String> getParameterNames() {
616618
}
617619

618620
@Override
619-
public @Nullable String[] getParameterValues(String name) {
621+
public String @Nullable [] getParameterValues(String name) {
620622
Assert.notNull(name, "Parameter name must not be null");
621623
return this.parameters.get(name);
622624
}
@@ -998,7 +1000,7 @@ public void setAuthType(@Nullable String authType) {
9981000
return this.authType;
9991001
}
10001002

1001-
public void setCookies(@Nullable Cookie... cookies) {
1003+
public void setCookies(Cookie @Nullable ... cookies) {
10021004
this.cookies = (ObjectUtils.isEmpty(cookies) ? null : cookies);
10031005
if (this.cookies == null) {
10041006
removeHeader(HttpHeaders.COOKIE);
@@ -1015,7 +1017,7 @@ private static String encodeCookies(Cookie... cookies) {
10151017
}
10161018

10171019
@Override
1018-
public @Nullable Cookie[] getCookies() {
1020+
public Cookie @Nullable [] getCookies() {
10191021
return this.cookies;
10201022
}
10211023

@@ -1310,6 +1312,7 @@ public void setSession(HttpSession session) {
13101312
}
13111313

13121314
@Override
1315+
@Contract("true -> !null")
13131316
public @Nullable HttpSession getSession(boolean create) {
13141317
checkActive();
13151318
// Reset session if invalidated.
@@ -1324,7 +1327,7 @@ public void setSession(HttpSession session) {
13241327
}
13251328

13261329
@Override
1327-
public @Nullable HttpSession getSession() {
1330+
public HttpSession getSession() {
13281331
return getSession(true);
13291332
}
13301333

0 commit comments

Comments
 (0)