mirror of
https://github.com/spring-projects/spring-framework.git
synced 2026-09-24 07:39:09 +00:00
Merge branch '7.0.x'
This commit is contained in:
@@ -66,6 +66,7 @@ import org.jspecify.annotations.Nullable;
|
||||
|
||||
import org.springframework.http.HttpHeaders;
|
||||
import org.springframework.http.MediaType;
|
||||
import org.springframework.lang.Contract;
|
||||
import org.springframework.util.Assert;
|
||||
import org.springframework.util.LinkedCaseInsensitiveMap;
|
||||
import org.springframework.util.LinkedMultiValueMap;
|
||||
@@ -1311,6 +1312,7 @@ public class MockHttpServletRequest implements HttpServletRequest {
|
||||
}
|
||||
|
||||
@Override
|
||||
@Contract("true -> !null")
|
||||
public @Nullable HttpSession getSession(boolean create) {
|
||||
checkActive();
|
||||
// Reset session if invalidated.
|
||||
@@ -1325,7 +1327,7 @@ public class MockHttpServletRequest implements HttpServletRequest {
|
||||
}
|
||||
|
||||
@Override
|
||||
public @Nullable HttpSession getSession() {
|
||||
public HttpSession getSession() {
|
||||
return getSession(true);
|
||||
}
|
||||
|
||||
|
||||
+10
-7
@@ -66,6 +66,7 @@ import org.jspecify.annotations.Nullable;
|
||||
|
||||
import org.springframework.http.HttpHeaders;
|
||||
import org.springframework.http.MediaType;
|
||||
import org.springframework.lang.Contract;
|
||||
import org.springframework.util.Assert;
|
||||
import org.springframework.util.LinkedCaseInsensitiveMap;
|
||||
import org.springframework.util.LinkedMultiValueMap;
|
||||
@@ -222,7 +223,7 @@ public class MockHttpServletRequest implements HttpServletRequest {
|
||||
|
||||
private @Nullable String authType;
|
||||
|
||||
private @Nullable Cookie[] cookies;
|
||||
private Cookie @Nullable [] cookies;
|
||||
|
||||
private final Map<String, HeaderValueHolder> headers = new LinkedCaseInsensitiveMap<>();
|
||||
|
||||
@@ -392,7 +393,8 @@ public class MockHttpServletRequest implements HttpServletRequest {
|
||||
private void updateContentTypeHeader() {
|
||||
if (StringUtils.hasLength(this.contentType)) {
|
||||
String value = this.contentType;
|
||||
if (StringUtils.hasLength(this.characterEncoding) && !this.contentType.toLowerCase().contains(CHARSET_PREFIX)) {
|
||||
if (StringUtils.hasLength(this.characterEncoding) &&
|
||||
!this.contentType.toLowerCase(Locale.ROOT).contains(CHARSET_PREFIX)) {
|
||||
value += ';' + CHARSET_PREFIX + this.characterEncoding;
|
||||
}
|
||||
doAddHeaderValue(HttpHeaders.CONTENT_TYPE, value, true);
|
||||
@@ -468,7 +470,7 @@ public class MockHttpServletRequest implements HttpServletRequest {
|
||||
}
|
||||
catch (IllegalArgumentException ex) {
|
||||
// Try to get charset value anyway
|
||||
contentType = contentType.toLowerCase();
|
||||
contentType = contentType.toLowerCase(Locale.ROOT);
|
||||
int charsetIndex = contentType.indexOf(CHARSET_PREFIX);
|
||||
if (charsetIndex != -1) {
|
||||
this.characterEncoding = contentType.substring(charsetIndex + CHARSET_PREFIX.length());
|
||||
@@ -616,7 +618,7 @@ public class MockHttpServletRequest implements HttpServletRequest {
|
||||
}
|
||||
|
||||
@Override
|
||||
public @Nullable String[] getParameterValues(String name) {
|
||||
public String @Nullable [] getParameterValues(String name) {
|
||||
Assert.notNull(name, "Parameter name must not be null");
|
||||
return this.parameters.get(name);
|
||||
}
|
||||
@@ -998,7 +1000,7 @@ public class MockHttpServletRequest implements HttpServletRequest {
|
||||
return this.authType;
|
||||
}
|
||||
|
||||
public void setCookies(@Nullable Cookie... cookies) {
|
||||
public void setCookies(Cookie @Nullable ... cookies) {
|
||||
this.cookies = (ObjectUtils.isEmpty(cookies) ? null : cookies);
|
||||
if (this.cookies == null) {
|
||||
removeHeader(HttpHeaders.COOKIE);
|
||||
@@ -1015,7 +1017,7 @@ public class MockHttpServletRequest implements HttpServletRequest {
|
||||
}
|
||||
|
||||
@Override
|
||||
public @Nullable Cookie[] getCookies() {
|
||||
public Cookie @Nullable [] getCookies() {
|
||||
return this.cookies;
|
||||
}
|
||||
|
||||
@@ -1310,6 +1312,7 @@ public class MockHttpServletRequest implements HttpServletRequest {
|
||||
}
|
||||
|
||||
@Override
|
||||
@Contract("true -> !null")
|
||||
public @Nullable HttpSession getSession(boolean create) {
|
||||
checkActive();
|
||||
// Reset session if invalidated.
|
||||
@@ -1324,7 +1327,7 @@ public class MockHttpServletRequest implements HttpServletRequest {
|
||||
}
|
||||
|
||||
@Override
|
||||
public @Nullable HttpSession getSession() {
|
||||
public HttpSession getSession() {
|
||||
return getSession(true);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user