, Serializable
* This is the common constructor, using a case-insensitive map structure.
*/
public HttpHeaders() {
- this(CollectionUtils.toMultiValueMap(new LinkedCaseInsensitiveMap<>(8, Locale.ENGLISH)));
+ this(CollectionUtils.toMultiValueMap(new LinkedCaseInsensitiveMap<>(8, Locale.ROOT)));
}
/**
@@ -684,7 +684,7 @@ public HttpMethod getAccessControlRequestMethod() {
public void setAcceptCharset(List acceptableCharsets) {
StringJoiner joiner = new StringJoiner(", ");
for (Charset charset : acceptableCharsets) {
- joiner.add(charset.name().toLowerCase(Locale.ENGLISH));
+ joiner.add(charset.name().toLowerCase(Locale.ROOT));
}
set(ACCEPT_CHARSET, joiner.toString());
}
diff --git a/spring-web/src/main/java/org/springframework/http/MediaTypeFactory.java b/spring-web/src/main/java/org/springframework/http/MediaTypeFactory.java
index b61cfea07350..f6da6eabf9c4 100644
--- a/spring-web/src/main/java/org/springframework/http/MediaTypeFactory.java
+++ b/spring-web/src/main/java/org/springframework/http/MediaTypeFactory.java
@@ -77,7 +77,7 @@ private static MultiValueMap parseMimeTypes() {
String[] tokens = StringUtils.tokenizeToStringArray(line, " \t\n\r\f");
MediaType mediaType = MediaType.parseMediaType(tokens[0]);
for (int i = 1; i < tokens.length; i++) {
- String fileExtension = tokens[i].toLowerCase(Locale.ENGLISH);
+ String fileExtension = tokens[i].toLowerCase(Locale.ROOT);
result.add(fileExtension, mediaType);
}
}
@@ -117,7 +117,7 @@ public static List getMediaTypes(@Nullable String filename) {
List mediaTypes = null;
String ext = StringUtils.getFilenameExtension(filename);
if (ext != null) {
- mediaTypes = fileExtensionToMediaTypes.get(ext.toLowerCase(Locale.ENGLISH));
+ mediaTypes = fileExtensionToMediaTypes.get(ext.toLowerCase(Locale.ROOT));
}
return (mediaTypes != null ? mediaTypes : Collections.emptyList());
}
diff --git a/spring-web/src/main/java/org/springframework/http/server/reactive/ServletServerHttpRequest.java b/spring-web/src/main/java/org/springframework/http/server/reactive/ServletServerHttpRequest.java
index 4a86019c74e0..8ad154927bf0 100644
--- a/spring-web/src/main/java/org/springframework/http/server/reactive/ServletServerHttpRequest.java
+++ b/spring-web/src/main/java/org/springframework/http/server/reactive/ServletServerHttpRequest.java
@@ -107,7 +107,7 @@ public ServletServerHttpRequest(MultiValueMap headers, HttpServl
private static MultiValueMap createDefaultHttpHeaders(HttpServletRequest request) {
MultiValueMap headers =
- CollectionUtils.toMultiValueMap(new LinkedCaseInsensitiveMap<>(8, Locale.ENGLISH));
+ CollectionUtils.toMultiValueMap(new LinkedCaseInsensitiveMap<>(8, Locale.ROOT));
for (Enumeration> names = request.getHeaderNames(); names.hasMoreElements(); ) {
String name = (String) names.nextElement();
for (Enumeration> values = request.getHeaders(name); values.hasMoreElements(); ) {
diff --git a/spring-web/src/main/java/org/springframework/remoting/httpinvoker/HttpComponentsHttpInvokerRequestExecutor.java b/spring-web/src/main/java/org/springframework/remoting/httpinvoker/HttpComponentsHttpInvokerRequestExecutor.java
index c8a278fec427..5949cd4a3087 100644
--- a/spring-web/src/main/java/org/springframework/remoting/httpinvoker/HttpComponentsHttpInvokerRequestExecutor.java
+++ b/spring-web/src/main/java/org/springframework/remoting/httpinvoker/HttpComponentsHttpInvokerRequestExecutor.java
@@ -364,7 +364,7 @@ protected InputStream getResponseBody(HttpInvokerClientConfiguration config, Htt
protected boolean isGzipResponse(HttpResponse httpResponse) {
Header encodingHeader = httpResponse.getFirstHeader(HTTP_HEADER_CONTENT_ENCODING);
return (encodingHeader != null && encodingHeader.getValue() != null &&
- encodingHeader.getValue().toLowerCase().contains(ENCODING_GZIP));
+ encodingHeader.getValue().toLowerCase(Locale.ROOT).contains(ENCODING_GZIP));
}
}
diff --git a/spring-web/src/main/java/org/springframework/remoting/httpinvoker/SimpleHttpInvokerRequestExecutor.java b/spring-web/src/main/java/org/springframework/remoting/httpinvoker/SimpleHttpInvokerRequestExecutor.java
index b4c8f31c364b..0cfdd3eff2a3 100644
--- a/spring-web/src/main/java/org/springframework/remoting/httpinvoker/SimpleHttpInvokerRequestExecutor.java
+++ b/spring-web/src/main/java/org/springframework/remoting/httpinvoker/SimpleHttpInvokerRequestExecutor.java
@@ -227,7 +227,7 @@ protected InputStream readResponseBody(HttpInvokerClientConfiguration config, Ht
*/
protected boolean isGzipResponse(HttpURLConnection con) {
String encodingHeader = con.getHeaderField(HTTP_HEADER_CONTENT_ENCODING);
- return (encodingHeader != null && encodingHeader.toLowerCase().contains(ENCODING_GZIP));
+ return (encodingHeader != null && encodingHeader.toLowerCase(Locale.ROOT).contains(ENCODING_GZIP));
}
}
diff --git a/spring-web/src/main/java/org/springframework/web/accept/MappingMediaTypeFileExtensionResolver.java b/spring-web/src/main/java/org/springframework/web/accept/MappingMediaTypeFileExtensionResolver.java
index a0ee49a56953..da1e41114e3c 100644
--- a/spring-web/src/main/java/org/springframework/web/accept/MappingMediaTypeFileExtensionResolver.java
+++ b/spring-web/src/main/java/org/springframework/web/accept/MappingMediaTypeFileExtensionResolver.java
@@ -109,7 +109,7 @@ public List getAllFileExtensions() {
*/
@Nullable
protected MediaType lookupMediaType(String extension) {
- return this.mediaTypes.get(extension.toLowerCase(Locale.ENGLISH));
+ return this.mediaTypes.get(extension.toLowerCase(Locale.ROOT);
}
}
diff --git a/spring-web/src/main/java/org/springframework/web/multipart/support/MultipartResolutionDelegate.java b/spring-web/src/main/java/org/springframework/web/multipart/support/MultipartResolutionDelegate.java
index 7d554e9052d7..5bb0670cea17 100644
--- a/spring-web/src/main/java/org/springframework/web/multipart/support/MultipartResolutionDelegate.java
+++ b/spring-web/src/main/java/org/springframework/web/multipart/support/MultipartResolutionDelegate.java
@@ -71,7 +71,7 @@ public static boolean isMultipartRequest(HttpServletRequest request) {
private static boolean isMultipartContent(HttpServletRequest request) {
String contentType = request.getContentType();
- return (contentType != null && contentType.toLowerCase().startsWith("multipart/"));
+ return (contentType != null && contentType.toLowerCase(Locale.ROOT).startsWith("multipart/"));
}
static MultipartHttpServletRequest asMultipartHttpServletRequest(HttpServletRequest request) {
diff --git a/spring-web/src/main/java/org/springframework/web/multipart/support/StandardMultipartHttpServletRequest.java b/spring-web/src/main/java/org/springframework/web/multipart/support/StandardMultipartHttpServletRequest.java
index 88bfdd4f2aa9..68502d5273bd 100644
--- a/spring-web/src/main/java/org/springframework/web/multipart/support/StandardMultipartHttpServletRequest.java
+++ b/spring-web/src/main/java/org/springframework/web/multipart/support/StandardMultipartHttpServletRequest.java
@@ -119,7 +119,7 @@ private void parseRequest(HttpServletRequest request) {
protected void handleParseFailure(Throwable ex) {
String msg = ex.getMessage();
if (msg != null) {
- msg = msg.toLowerCase();
+ msg = msg.toLowerCase(Locale.ROOT);
if (msg.contains("size") && msg.contains("exceed")) {
throw new MaxUploadSizeExceededException(-1, ex);
}
diff --git a/spring-web/src/main/java/org/springframework/web/server/adapter/HttpWebHandlerAdapter.java b/spring-web/src/main/java/org/springframework/web/server/adapter/HttpWebHandlerAdapter.java
index 76cae2917861..9965362a549d 100644
--- a/spring-web/src/main/java/org/springframework/web/server/adapter/HttpWebHandlerAdapter.java
+++ b/spring-web/src/main/java/org/springframework/web/server/adapter/HttpWebHandlerAdapter.java
@@ -314,7 +314,7 @@ else if (lostClientLogger.isDebugEnabled()) {
private boolean isDisconnectedClientError(Throwable ex) {
String message = NestedExceptionUtils.getMostSpecificCause(ex).getMessage();
if (message != null) {
- String text = message.toLowerCase();
+ String text = message.toLowerCase(Locale.ROOT);
if (text.contains("broken pipe") || text.contains("connection reset by peer")) {
return true;
}
diff --git a/spring-web/src/main/java/org/springframework/web/util/UriComponentsBuilder.java b/spring-web/src/main/java/org/springframework/web/util/UriComponentsBuilder.java
index 4d1d07c808ad..e60d2e5bffd2 100644
--- a/spring-web/src/main/java/org/springframework/web/util/UriComponentsBuilder.java
+++ b/spring-web/src/main/java/org/springframework/web/util/UriComponentsBuilder.java
@@ -291,7 +291,7 @@ public static UriComponentsBuilder fromHttpUrl(String httpUrl) {
if (matcher.matches()) {
UriComponentsBuilder builder = new UriComponentsBuilder();
String scheme = matcher.group(1);
- builder.scheme(scheme != null ? scheme.toLowerCase() : null);
+ builder.scheme(scheme != null ? scheme.toLowerCase(Locale.ROOT) : null);
builder.userInfo(matcher.group(4));
String host = matcher.group(5);
checkSchemeAndHost(httpUrl, scheme, host);
diff --git a/spring-web/src/main/java/org/springframework/web/util/UrlPathHelper.java b/spring-web/src/main/java/org/springframework/web/util/UrlPathHelper.java
index d347cd516ae4..0c3601f512e2 100644
--- a/spring-web/src/main/java/org/springframework/web/util/UrlPathHelper.java
+++ b/spring-web/src/main/java/org/springframework/web/util/UrlPathHelper.java
@@ -635,7 +635,7 @@ private static String removeSemicolonContentInternal(String requestUri) {
private String removeJsessionid(String requestUri) {
String key = ";jsessionid=";
- int index = requestUri.toLowerCase().indexOf(key);
+ int index = requestUri.toLowerCase(Locale.ROOT).indexOf(key);
if (index == -1) {
return requestUri;
}
diff --git a/spring-web/src/testFixtures/java/org/springframework/web/testfixture/servlet/MockHttpServletRequest.java b/spring-web/src/testFixtures/java/org/springframework/web/testfixture/servlet/MockHttpServletRequest.java
index 1df60c636efe..ef0e3b026e2c 100644
--- a/spring-web/src/testFixtures/java/org/springframework/web/testfixture/servlet/MockHttpServletRequest.java
+++ b/spring-web/src/testFixtures/java/org/springframework/web/testfixture/servlet/MockHttpServletRequest.java
@@ -409,7 +409,7 @@ public void setCharacterEncoding(@Nullable String characterEncoding) {
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);
@@ -487,7 +487,7 @@ public void setContentType(@Nullable String contentType) {
}
catch (IllegalArgumentException ex) {
// Try to get charset value anyway
- int charsetIndex = contentType.toLowerCase().indexOf(CHARSET_PREFIX);
+ int charsetIndex = contentType.toLowerCase(Locale.ROOT).indexOf(CHARSET_PREFIX);
if (charsetIndex != -1) {
this.characterEncoding = contentType.substring(charsetIndex + CHARSET_PREFIX.length());
}
diff --git a/spring-web/src/testFixtures/java/org/springframework/web/testfixture/servlet/MockHttpServletResponse.java b/spring-web/src/testFixtures/java/org/springframework/web/testfixture/servlet/MockHttpServletResponse.java
index 82e80e191c94..0d57814a8ef5 100644
--- a/spring-web/src/testFixtures/java/org/springframework/web/testfixture/servlet/MockHttpServletResponse.java
+++ b/spring-web/src/testFixtures/java/org/springframework/web/testfixture/servlet/MockHttpServletResponse.java
@@ -215,7 +215,7 @@ private void setExplicitCharacterEncoding(String characterEncoding) {
private void updateContentTypePropertyAndHeader() {
if (this.contentType != null) {
String value = this.contentType;
- if (this.characterEncodingSet && !value.toLowerCase().contains(CHARSET_PREFIX)) {
+ if (this.characterEncodingSet && !value.toLowerCase(Locale.ROOT).contains(CHARSET_PREFIX)) {
value += ';' + CHARSET_PREFIX + getCharacterEncoding();
this.contentType = value;
}
@@ -315,7 +315,7 @@ public void setContentType(@Nullable String contentType) {
}
catch (Exception ex) {
// Try to get charset value anyway
- int charsetIndex = contentType.toLowerCase().indexOf(CHARSET_PREFIX);
+ int charsetIndex = contentType.toLowerCase(Locale.ROOT).indexOf(CHARSET_PREFIX);
if (charsetIndex != -1) {
setExplicitCharacterEncoding(contentType.substring(charsetIndex + CHARSET_PREFIX.length()));
}
diff --git a/spring-webflux/src/main/java/org/springframework/web/reactive/resource/CachingResourceResolver.java b/spring-webflux/src/main/java/org/springframework/web/reactive/resource/CachingResourceResolver.java
index 015b3889172d..f5bd80a99868 100644
--- a/spring-webflux/src/main/java/org/springframework/web/reactive/resource/CachingResourceResolver.java
+++ b/spring-webflux/src/main/java/org/springframework/web/reactive/resource/CachingResourceResolver.java
@@ -140,7 +140,7 @@ private String getContentCodingKey(ServerWebExchange exchange) {
return Arrays.stream(StringUtils.tokenizeToStringArray(header, ","))
.map(token -> {
int index = token.indexOf(';');
- return (index >= 0 ? token.substring(0, index) : token).trim().toLowerCase();
+ return (index >= 0 ? token.substring(0, index) : token).trim().toLowerCase(Locale.ROOT);
})
.filter(this.contentCodings::contains)
.sorted()
diff --git a/spring-webflux/src/main/java/org/springframework/web/reactive/resource/EncodedResourceResolver.java b/spring-webflux/src/main/java/org/springframework/web/reactive/resource/EncodedResourceResolver.java
index 1bbdb443011d..79027920487c 100644
--- a/spring-webflux/src/main/java/org/springframework/web/reactive/resource/EncodedResourceResolver.java
+++ b/spring-webflux/src/main/java/org/springframework/web/reactive/resource/EncodedResourceResolver.java
@@ -168,7 +168,7 @@ protected Mono resolveResourceInternal(@Nullable ServerWebExchange exc
private String getAcceptEncoding(ServerWebExchange exchange) {
ServerHttpRequest request = exchange.getRequest();
String header = request.getHeaders().getFirst(HttpHeaders.ACCEPT_ENCODING);
- return (header != null ? header.toLowerCase() : null);
+ return (header != null ? header.toLowerCase(Locale.ROOT) : null);
}
private String getExtension(String coding) {
diff --git a/spring-webflux/src/main/java/org/springframework/web/reactive/resource/GzipResourceResolver.java b/spring-webflux/src/main/java/org/springframework/web/reactive/resource/GzipResourceResolver.java
index 74a7a628bb9b..417b677e30df 100644
--- a/spring-webflux/src/main/java/org/springframework/web/reactive/resource/GzipResourceResolver.java
+++ b/spring-webflux/src/main/java/org/springframework/web/reactive/resource/GzipResourceResolver.java
@@ -69,7 +69,7 @@ protected Mono resolveResourceInternal(@Nullable ServerWebExchange exc
private boolean isGzipAccepted(ServerWebExchange exchange) {
String value = exchange.getRequest().getHeaders().getFirst("Accept-Encoding");
- return (value != null && value.toLowerCase().contains("gzip"));
+ return (value != null && value.toLowerCase(Locale.ROOT).contains("gzip"));
}
@Override
diff --git a/spring-webflux/src/main/java/org/springframework/web/reactive/resource/ResourceWebHandler.java b/spring-webflux/src/main/java/org/springframework/web/reactive/resource/ResourceWebHandler.java
index 7c4db588b450..178d098d3f74 100644
--- a/spring-webflux/src/main/java/org/springframework/web/reactive/resource/ResourceWebHandler.java
+++ b/spring-webflux/src/main/java/org/springframework/web/reactive/resource/ResourceWebHandler.java
@@ -605,7 +605,7 @@ private MediaType getMediaType(Resource resource) {
if (!CollectionUtils.isEmpty(this.mediaTypes)) {
String ext = StringUtils.getFilenameExtension(filename);
if (ext != null) {
- mediaType = this.mediaTypes.get(ext.toLowerCase(Locale.ENGLISH));
+ mediaType = this.mediaTypes.get(ext.toLowerCase(Locale.ROOT);
}
}
if (mediaType == null) {
diff --git a/spring-webflux/src/main/java/org/springframework/web/reactive/result/condition/AbstractNameValueExpression.java b/spring-webflux/src/main/java/org/springframework/web/reactive/result/condition/AbstractNameValueExpression.java
index 37b4ee985842..1cc698a9936f 100644
--- a/spring-webflux/src/main/java/org/springframework/web/reactive/result/condition/AbstractNameValueExpression.java
+++ b/spring-webflux/src/main/java/org/springframework/web/reactive/result/condition/AbstractNameValueExpression.java
@@ -106,7 +106,7 @@ public boolean equals(@Nullable Object other) {
@Override
public int hashCode() {
- int result = (isCaseSensitiveName() ? this.name : this.name.toLowerCase()).hashCode();
+ int result = (isCaseSensitiveName() ? this.name : this.name.toLowerCase(Locale.ROOT)).hashCode();
result = 31 * result + ObjectUtils.nullSafeHashCode(this.value);
result = 31 * result + (this.isNegated ? 1 : 0);
return result;
diff --git a/spring-webflux/src/test/java/org/springframework/web/reactive/FlushingIntegrationTests.java b/spring-webflux/src/test/java/org/springframework/web/reactive/FlushingIntegrationTests.java
index 6663fa62196a..4893cfa1e577 100644
--- a/spring-webflux/src/test/java/org/springframework/web/reactive/FlushingIntegrationTests.java
+++ b/spring-webflux/src/test/java/org/springframework/web/reactive/FlushingIntegrationTests.java
@@ -86,7 +86,7 @@ void writeAndAutoFlushOnComplete(HttpServer httpServer) throws Exception {
.verify(Duration.ofSeconds(10L));
}
catch (AssertionError err) {
- String os = System.getProperty("os.name").toLowerCase();
+ String os = System.getProperty("os.name").toLowerCase(Locale.ROOT);
if (os.contains("windows") && err.getMessage() != null &&
err.getMessage().startsWith("VerifySubscriber timed out")) {
// TODO: Reactor usually times out on Windows ...
diff --git a/spring-webflux/src/test/java/org/springframework/web/reactive/result/method/annotation/RequestMappingHandlerMappingTests.java b/spring-webflux/src/test/java/org/springframework/web/reactive/result/method/annotation/RequestMappingHandlerMappingTests.java
index 293ce04780e4..bdf008fdca49 100644
--- a/spring-webflux/src/test/java/org/springframework/web/reactive/result/method/annotation/RequestMappingHandlerMappingTests.java
+++ b/spring-webflux/src/test/java/org/springframework/web/reactive/result/method/annotation/RequestMappingHandlerMappingTests.java
@@ -152,7 +152,7 @@ public void patchMapping() throws Exception {
private RequestMappingInfo assertComposedAnnotationMapping(RequestMethod requestMethod) throws Exception {
- String methodName = requestMethod.name().toLowerCase();
+ String methodName = requestMethod.name().toLowerCase(Locale.ROOT);
String path = "/" + methodName;
return assertComposedAnnotationMapping(methodName, path, requestMethod);
diff --git a/spring-webflux/src/test/java/org/springframework/web/reactive/result/method/annotation/RequestMappingIntegrationTests.java b/spring-webflux/src/test/java/org/springframework/web/reactive/result/method/annotation/RequestMappingIntegrationTests.java
index 9203e3025b15..a355a0a853e2 100644
--- a/spring-webflux/src/test/java/org/springframework/web/reactive/result/method/annotation/RequestMappingIntegrationTests.java
+++ b/spring-webflux/src/test/java/org/springframework/web/reactive/result/method/annotation/RequestMappingIntegrationTests.java
@@ -69,7 +69,7 @@ void httpHead(HttpServer httpServer) throws Exception {
HttpHeaders headers = getRestTemplate().headForHeaders(url);
String contentType = headers.getFirst("Content-Type");
assertThat(contentType).isNotNull();
- assertThat(contentType.toLowerCase()).isEqualTo("text/html;charset=utf-8");
+ assertThat(contentType.toLowerCase(Locale.ROOT)).isEqualTo("text/html;charset=utf-8");
assertThat(headers.getContentLength()).isEqualTo(3);
}
diff --git a/spring-webmvc/src/main/java/org/springframework/web/servlet/mvc/condition/AbstractNameValueExpression.java b/spring-webmvc/src/main/java/org/springframework/web/servlet/mvc/condition/AbstractNameValueExpression.java
index 5acc07c3dc44..4370a7630598 100644
--- a/spring-webmvc/src/main/java/org/springframework/web/servlet/mvc/condition/AbstractNameValueExpression.java
+++ b/spring-webmvc/src/main/java/org/springframework/web/servlet/mvc/condition/AbstractNameValueExpression.java
@@ -108,7 +108,7 @@ public boolean equals(@Nullable Object other) {
@Override
public int hashCode() {
- int result = (isCaseSensitiveName() ? this.name.hashCode() : this.name.toLowerCase().hashCode());
+ int result = (isCaseSensitiveName() ? this.name.hashCode() : this.name.toLowerCase(Locale.ROOT).hashCode());
result = 31 * result + (this.value != null ? this.value.hashCode() : 0);
result = 31 * result + (this.isNegated ? 1 : 0);
return result;
diff --git a/spring-webmvc/src/main/java/org/springframework/web/servlet/resource/CachingResourceResolver.java b/spring-webmvc/src/main/java/org/springframework/web/servlet/resource/CachingResourceResolver.java
index 762c84884150..589f8c7ab989 100644
--- a/spring-webmvc/src/main/java/org/springframework/web/servlet/resource/CachingResourceResolver.java
+++ b/spring-webmvc/src/main/java/org/springframework/web/servlet/resource/CachingResourceResolver.java
@@ -146,7 +146,7 @@ private String getContentCodingKey(HttpServletRequest request) {
return Arrays.stream(StringUtils.tokenizeToStringArray(header, ","))
.map(token -> {
int index = token.indexOf(';');
- return (index >= 0 ? token.substring(0, index) : token).trim().toLowerCase();
+ return (index >= 0 ? token.substring(0, index) : token).trim().toLowerCase(Locale.ROOT);
})
.filter(this.contentCodings::contains)
.sorted()
diff --git a/spring-webmvc/src/main/java/org/springframework/web/servlet/resource/EncodedResourceResolver.java b/spring-webmvc/src/main/java/org/springframework/web/servlet/resource/EncodedResourceResolver.java
index c4dbaa038df3..450447ca252a 100644
--- a/spring-webmvc/src/main/java/org/springframework/web/servlet/resource/EncodedResourceResolver.java
+++ b/spring-webmvc/src/main/java/org/springframework/web/servlet/resource/EncodedResourceResolver.java
@@ -164,7 +164,7 @@ protected Resource resolveResourceInternal(@Nullable HttpServletRequest request,
@Nullable
private String getAcceptEncoding(HttpServletRequest request) {
String header = request.getHeader(HttpHeaders.ACCEPT_ENCODING);
- return (header != null ? header.toLowerCase() : null);
+ return (header != null ? header.toLowerCase(Locale.ROOT) : null);
}
private String getExtension(String coding) {
diff --git a/spring-webmvc/src/main/java/org/springframework/web/servlet/resource/GzipResourceResolver.java b/spring-webmvc/src/main/java/org/springframework/web/servlet/resource/GzipResourceResolver.java
index f7b8542befae..e642f30e74b9 100644
--- a/spring-webmvc/src/main/java/org/springframework/web/servlet/resource/GzipResourceResolver.java
+++ b/spring-webmvc/src/main/java/org/springframework/web/servlet/resource/GzipResourceResolver.java
@@ -70,7 +70,7 @@ protected Resource resolveResourceInternal(@Nullable HttpServletRequest request,
private boolean isGzipAccepted(HttpServletRequest request) {
String value = request.getHeader("Accept-Encoding");
- return (value != null && value.toLowerCase().contains("gzip"));
+ return (value != null && value.toLowerCase(Locale.ROOT).contains("gzip"));
}
@Override
diff --git a/spring-webmvc/src/main/java/org/springframework/web/servlet/resource/ResourceHttpRequestHandler.java b/spring-webmvc/src/main/java/org/springframework/web/servlet/resource/ResourceHttpRequestHandler.java
index f5a1ada29408..5ccbdd9debad 100644
--- a/spring-webmvc/src/main/java/org/springframework/web/servlet/resource/ResourceHttpRequestHandler.java
+++ b/spring-webmvc/src/main/java/org/springframework/web/servlet/resource/ResourceHttpRequestHandler.java
@@ -786,7 +786,7 @@ protected MediaType getMediaType(HttpServletRequest request, Resource resource)
String filename = resource.getFilename();
String ext = StringUtils.getFilenameExtension(filename);
if (ext != null) {
- mediaType = this.mediaTypes.get(ext.toLowerCase(Locale.ENGLISH));
+ mediaType = this.mediaTypes.get(ext.toLowerCase(Locale.ROOT);
}
if (mediaType == null) {
List mediaTypes = MediaTypeFactory.getMediaTypes(filename);
diff --git a/spring-webmvc/src/main/java/org/springframework/web/servlet/view/xslt/XsltView.java b/spring-webmvc/src/main/java/org/springframework/web/servlet/view/xslt/XsltView.java
index e0383c5e3227..19dc1d9eedca 100644
--- a/spring-webmvc/src/main/java/org/springframework/web/servlet/view/xslt/XsltView.java
+++ b/spring-webmvc/src/main/java/org/springframework/web/servlet/view/xslt/XsltView.java
@@ -415,7 +415,7 @@ protected void configureResponse(Map model, HttpServletResponse
}
if (StringUtils.hasText(encoding)) {
// Only apply encoding if content type is specified but does not contain charset clause already.
- if (contentType != null && !contentType.toLowerCase().contains(WebUtils.CONTENT_TYPE_CHARSET_PREFIX)) {
+ if (contentType != null && !contentType.toLowerCase(Locale.ROOT).contains(WebUtils.CONTENT_TYPE_CHARSET_PREFIX)) {
contentType = contentType + WebUtils.CONTENT_TYPE_CHARSET_PREFIX + encoding;
}
}
diff --git a/spring-webmvc/src/test/java/org/springframework/web/servlet/mvc/method/annotation/RequestMappingHandlerMappingTests.java b/spring-webmvc/src/test/java/org/springframework/web/servlet/mvc/method/annotation/RequestMappingHandlerMappingTests.java
index 9ed74e07817e..d34516048061 100644
--- a/spring-webmvc/src/test/java/org/springframework/web/servlet/mvc/method/annotation/RequestMappingHandlerMappingTests.java
+++ b/spring-webmvc/src/test/java/org/springframework/web/servlet/mvc/method/annotation/RequestMappingHandlerMappingTests.java
@@ -282,7 +282,7 @@ private RequestMappingInfo assertComposedAnnotationMapping(RequestMethod request
RequestMappingHandlerMapping mapping = new RequestMappingHandlerMapping();
mapping.setApplicationContext(new StaticWebApplicationContext());
- String methodName = requestMethod.name().toLowerCase();
+ String methodName = requestMethod.name().toLowerCase(Locale.ROOT);
String path = "/" + methodName;
return assertComposedAnnotationMapping(mapping, methodName, path, requestMethod);
diff --git a/spring-webmvc/src/test/java/org/springframework/web/servlet/tags/form/CheckboxesTagTests.java b/spring-webmvc/src/test/java/org/springframework/web/servlet/tags/form/CheckboxesTagTests.java
index c7455c7f859d..72396e8296a0 100644
--- a/spring-webmvc/src/test/java/org/springframework/web/servlet/tags/form/CheckboxesTagTests.java
+++ b/spring-webmvc/src/test/java/org/springframework/web/servlet/tags/form/CheckboxesTagTests.java
@@ -798,7 +798,7 @@ private static class MyLowerCaseEditor extends PropertyEditorSupport {
@Override
public void setAsText(String text) throws IllegalArgumentException {
- setValue(text.toLowerCase());
+ setValue(text.toLowerCase(Locale.ROOT));
}
@Override
diff --git a/spring-websocket/src/main/java/org/springframework/web/socket/client/AbstractWebSocketClient.java b/spring-websocket/src/main/java/org/springframework/web/socket/client/AbstractWebSocketClient.java
index 03cdeac6cfc8..297191c3c44a 100644
--- a/spring-websocket/src/main/java/org/springframework/web/socket/client/AbstractWebSocketClient.java
+++ b/spring-websocket/src/main/java/org/springframework/web/socket/client/AbstractWebSocketClient.java
@@ -85,7 +85,7 @@ public final ListenableFuture doHandshake(WebSocketHandler web
HttpHeaders headersToUse = new HttpHeaders();
if (headers != null) {
headers.forEach((header, values) -> {
- if (values != null && !specialHeaders.contains(header.toLowerCase())) {
+ if (values != null && !specialHeaders.contains(header.toLowerCase(Locale.ROOT))) {
headersToUse.put(header, values);
}
});
diff --git a/spring-websocket/src/main/java/org/springframework/web/socket/server/support/AbstractHandshakeHandler.java b/spring-websocket/src/main/java/org/springframework/web/socket/server/support/AbstractHandshakeHandler.java
index 918c84298d5e..2683c40ff9b7 100644
--- a/spring-websocket/src/main/java/org/springframework/web/socket/server/support/AbstractHandshakeHandler.java
+++ b/spring-websocket/src/main/java/org/springframework/web/socket/server/support/AbstractHandshakeHandler.java
@@ -192,7 +192,7 @@ public RequestUpgradeStrategy getRequestUpgradeStrategy() {
public void setSupportedProtocols(String... protocols) {
this.supportedProtocols.clear();
for (String protocol : protocols) {
- this.supportedProtocols.add(protocol.toLowerCase());
+ this.supportedProtocols.add(protocol.toLowerCase(Locale.ROOT));
}
}
@@ -367,10 +367,10 @@ protected boolean isValidOrigin(ServerHttpRequest request) {
protected String selectProtocol(List requestedProtocols, WebSocketHandler webSocketHandler) {
List handlerProtocols = determineHandlerSupportedProtocols(webSocketHandler);
for (String protocol : requestedProtocols) {
- if (handlerProtocols.contains(protocol.toLowerCase())) {
+ if (handlerProtocols.contains(protocol.toLowerCase(Locale.ROOT))) {
return protocol;
}
- if (this.supportedProtocols.contains(protocol.toLowerCase())) {
+ if (this.supportedProtocols.contains(protocol.toLowerCase(Locale.ROOT))) {
return protocol;
}
}
diff --git a/spring-websocket/src/main/java/org/springframework/web/socket/sockjs/frame/AbstractSockJsMessageCodec.java b/spring-websocket/src/main/java/org/springframework/web/socket/sockjs/frame/AbstractSockJsMessageCodec.java
index dbf3461f8bc6..9bf5b33d6702 100644
--- a/spring-websocket/src/main/java/org/springframework/web/socket/sockjs/frame/AbstractSockJsMessageCodec.java
+++ b/spring-websocket/src/main/java/org/springframework/web/socket/sockjs/frame/AbstractSockJsMessageCodec.java
@@ -58,7 +58,7 @@ private String escapeSockJsSpecialChars(char[] characters) {
for (char c : characters) {
if (isSockJsSpecialChar(c)) {
result.append('\\').append('u');
- String hex = Integer.toHexString(c).toLowerCase();
+ String hex = Integer.toHexString(c).toLowerCase(Locale.ROOT);
for (int i = 0; i < (4 - hex.length()); i++) {
result.append('0');
}
diff --git a/spring-websocket/src/main/java/org/springframework/web/socket/sockjs/transport/session/AbstractSockJsSession.java b/spring-websocket/src/main/java/org/springframework/web/socket/sockjs/transport/session/AbstractSockJsSession.java
index df2b745d53fb..160617fa53f5 100644
--- a/spring-websocket/src/main/java/org/springframework/web/socket/sockjs/transport/session/AbstractSockJsSession.java
+++ b/spring-websocket/src/main/java/org/springframework/web/socket/sockjs/transport/session/AbstractSockJsSession.java
@@ -364,7 +364,7 @@ else if (disconnectedClientLogger.isDebugEnabled()) {
private boolean indicatesDisconnectedClient(Throwable ex) {
String message = NestedExceptionUtils.getMostSpecificCause(ex).getMessage();
- message = (message != null ? message.toLowerCase() : "");
+ message = (message != null ? message.toLowerCase(Locale.ROOT) : "");
String className = ex.getClass().getSimpleName();
return (message.contains("broken pipe") || DISCONNECTED_CLIENT_EXCEPTIONS.contains(className));
}
diff --git a/spring-websocket/src/test/java/org/springframework/web/socket/sockjs/client/SockJsUrlInfoTests.java b/spring-websocket/src/test/java/org/springframework/web/socket/sockjs/client/SockJsUrlInfoTests.java
index 4e63e808cbf8..ddfe2c2af043 100644
--- a/spring-websocket/src/test/java/org/springframework/web/socket/sockjs/client/SockJsUrlInfoTests.java
+++ b/spring-websocket/src/test/java/org/springframework/web/socket/sockjs/client/SockJsUrlInfoTests.java
@@ -74,7 +74,7 @@ void transportUrl(String scheme, String expectedScheme, TransportType transportT
SockJsUrlInfo info = new SockJsUrlInfo(new URI(scheme + "://example.com"));
String serverId = info.getServerId();
String sessionId = info.getSessionId();
- String transport = transportType.toString().toLowerCase();
+ String transport = transportType.toString().toLowerCase(Locale.ROOT);
URI expected = new URI(expectedScheme + "://example.com/" + serverId + "/" + sessionId + "/" + transport);
assertThat(info.getTransportUrl(transportType)).isEqualTo(expected);
}
diff --git a/src/docs/asciidoc/testing.adoc b/src/docs/asciidoc/testing.adoc
index 264a2227da09..813945b85db5 100644
--- a/src/docs/asciidoc/testing.adoc
+++ b/src/docs/asciidoc/testing.adoc
@@ -1942,7 +1942,7 @@ within that class are automatically enabled by default as well.
Expressions can be any of the following:
* <> (SpEL) expression. For example:
- `@EnabledIf("#{systemProperties['os.name'].toLowerCase().contains('mac')}")`
+ `@EnabledIf("#{systemProperties['os.name'].toLowerCase(Locale.ROOT).contains('mac')}")`
* Placeholder for a property available in the Spring <>.
For example: `@EnabledIf("${smoke.tests.enabled}")`
* Text literal. For example: `@EnabledIf("true")`
@@ -1960,7 +1960,7 @@ example, you can create a custom `@EnabledOnMac` annotation as follows:
@Target({ElementType.TYPE, ElementType.METHOD})
@Retention(RetentionPolicy.RUNTIME)
@EnabledIf(
- expression = "#{systemProperties['os.name'].toLowerCase().contains('mac')}",
+ expression = "#{systemProperties['os.name'].toLowerCase(Locale.ROOT).contains('mac')}",
reason = "Enabled on Mac OS"
)
public @interface EnabledOnMac {}
@@ -1971,7 +1971,7 @@ example, you can create a custom `@EnabledOnMac` annotation as follows:
@Target(AnnotationTarget.TYPE, AnnotationTarget.FUNCTION)
@Retention(AnnotationRetention.RUNTIME)
@EnabledIf(
- expression = "#{systemProperties['os.name'].toLowerCase().contains('mac')}",
+ expression = "#{systemProperties['os.name'].toLowerCase(Locale.ROOT).contains('mac')}",
reason = "Enabled on Mac OS"
)
annotation class EnabledOnMac {}
@@ -2002,7 +2002,7 @@ test methods within that class are automatically disabled as well.
Expressions can be any of the following:
* <> (SpEL) expression. For example:
- `@DisabledIf("#{systemProperties['os.name'].toLowerCase().contains('mac')}")`
+ `@DisabledIf("#{systemProperties['os.name'].toLowerCase(Locale.ROOT).contains('mac')}")`
* Placeholder for a property available in the Spring <>.
For example: `@DisabledIf("${smoke.tests.disabled}")`
* Text literal. For example: `@DisabledIf("true")`
@@ -2020,7 +2020,7 @@ example, you can create a custom `@DisabledOnMac` annotation as follows:
@Target({ElementType.TYPE, ElementType.METHOD})
@Retention(RetentionPolicy.RUNTIME)
@DisabledIf(
- expression = "#{systemProperties['os.name'].toLowerCase().contains('mac')}",
+ expression = "#{systemProperties['os.name'].toLowerCase(Locale.ROOT).contains('mac')}",
reason = "Disabled on Mac OS"
)
public @interface DisabledOnMac {}
@@ -2032,7 +2032,7 @@ example, you can create a custom `@DisabledOnMac` annotation as follows:
@Target(AnnotationTarget.TYPE, AnnotationTarget.FUNCTION)
@Retention(AnnotationRetention.RUNTIME)
@DisabledIf(
- expression = "#{systemProperties['os.name'].toLowerCase().contains('mac')}",
+ expression = "#{systemProperties['os.name'].toLowerCase(Locale.ROOT).contains('mac')}",
reason = "Disabled on Mac OS"
)
annotation class DisabledOnMac {}