Merge branch '6.1.x'

This commit is contained in:
rstoyanchev 2024-10-16 12:11:23 +01:00
commit bdcfbee7df
42 changed files with 97 additions and 74 deletions

View File

@ -1,5 +1,5 @@
/*
* Copyright 2002-2023 the original author or authors.
* Copyright 2002-2024 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.
@ -16,6 +16,8 @@
package org.springframework.docs.integration.observability.config.conventions;
import java.util.Locale;
import io.micrometer.common.KeyValue;
import io.micrometer.common.KeyValues;
@ -34,7 +36,7 @@ public class CustomServerRequestObservationConvention implements ServerRequestOb
@Override
public String getContextualName(ServerRequestObservationContext context) {
// will be used for the trace name
return "http " + context.getCarrier().getMethod().toLowerCase();
return "http " + context.getCarrier().getMethod().toLowerCase(Locale.ROOT);
}
@Override

View File

@ -27,6 +27,7 @@ import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Locale;
import java.util.Map;
import java.util.Optional;
import java.util.Set;
@ -570,7 +571,8 @@ public class DataBinder implements PropertyEditorRegistry, TypeConverter {
else {
String[] fieldPatterns = new String[disallowedFields.length];
for (int i = 0; i < fieldPatterns.length; i++) {
fieldPatterns[i] = PropertyAccessorUtils.canonicalPropertyName(disallowedFields[i]).toLowerCase();
String field = PropertyAccessorUtils.canonicalPropertyName(disallowedFields[i]);
fieldPatterns[i] = field.toLowerCase(Locale.ROOT);
}
this.disallowedFields = fieldPatterns;
}
@ -1248,7 +1250,7 @@ public class DataBinder implements PropertyEditorRegistry, TypeConverter {
String[] allowed = getAllowedFields();
String[] disallowed = getDisallowedFields();
return ((ObjectUtils.isEmpty(allowed) || PatternMatchUtils.simpleMatch(allowed, field)) &&
(ObjectUtils.isEmpty(disallowed) || !PatternMatchUtils.simpleMatch(disallowed, field.toLowerCase())));
(ObjectUtils.isEmpty(disallowed) || !PatternMatchUtils.simpleMatch(disallowed, field.toLowerCase(Locale.ROOT))));
}
/**

View File

@ -1,5 +1,5 @@
/*
* Copyright 2002-2023 the original author or authors.
* Copyright 2002-2024 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.
@ -181,10 +181,10 @@ public class MimeType implements Comparable<MimeType>, Serializable {
Assert.hasLength(subtype, "'subtype' must not be empty");
checkToken(type);
checkToken(subtype);
this.type = type.toLowerCase(Locale.ENGLISH);
this.subtype = subtype.toLowerCase(Locale.ENGLISH);
this.type = type.toLowerCase(Locale.ROOT);
this.subtype = subtype.toLowerCase(Locale.ROOT);
if (!CollectionUtils.isEmpty(parameters)) {
Map<String, String> map = new LinkedCaseInsensitiveMap<>(parameters.size(), Locale.ENGLISH);
Map<String, String> map = new LinkedCaseInsensitiveMap<>(parameters.size(), Locale.ROOT);
parameters.forEach((parameter, value) -> {
checkParameters(parameter, value);
map.put(parameter, value);

View File

@ -412,7 +412,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);
@ -490,7 +491,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());

View File

@ -226,7 +226,7 @@ public class MockHttpServletResponse implements HttpServletResponse {
}
catch (Exception ignored) {
String value = this.contentType;
int charsetIndex = value.toLowerCase().indexOf(CHARSET_PREFIX);
int charsetIndex = value.toLowerCase(Locale.ROOT).indexOf(CHARSET_PREFIX);
if (charsetIndex != -1) {
value = value.substring(0, charsetIndex).trim();
if (value.endsWith(";")) {
@ -246,7 +246,7 @@ public class MockHttpServletResponse implements HttpServletResponse {
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;
}
@ -358,7 +358,7 @@ public class MockHttpServletResponse implements HttpServletResponse {
}
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()));
}

View File

@ -391,7 +391,7 @@ public class HttpHeaders implements MultiValueMap<String, String>, Serializable
*/
public static final HttpHeaders EMPTY = new ReadOnlyHttpHeaders(new LinkedMultiValueMap<>());
private static final DecimalFormatSymbols DECIMAL_FORMAT_SYMBOLS = new DecimalFormatSymbols(Locale.ENGLISH);
private static final DecimalFormatSymbols DECIMAL_FORMAT_SYMBOLS = new DecimalFormatSymbols(Locale.ROOT);
private static final ZoneId GMT = ZoneId.of("GMT");
@ -421,7 +421,7 @@ public class HttpHeaders implements MultiValueMap<String, String>, Serializable
* <p>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)));
}
/**
@ -717,7 +717,7 @@ public class HttpHeaders implements MultiValueMap<String, String>, Serializable
public void setAcceptCharset(List<Charset> 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());
}

View File

@ -1,5 +1,5 @@
/*
* Copyright 2002-2021 the original author or authors.
* Copyright 2002-2024 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.
@ -77,7 +77,7 @@ public final class MediaTypeFactory {
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 final class MediaTypeFactory {
List<MediaType> 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());
}

View File

@ -28,6 +28,7 @@ import java.net.http.HttpTimeoutException;
import java.nio.ByteBuffer;
import java.time.Duration;
import java.util.Collections;
import java.util.Locale;
import java.util.Set;
import java.util.TreeSet;
import java.util.concurrent.CancellationException;
@ -141,7 +142,7 @@ class JdkClientHttpRequest extends AbstractStreamingClientHttpRequest {
HttpRequest.Builder builder = HttpRequest.newBuilder().uri(this.uri);
headers.forEach((headerName, headerValues) -> {
if (!DISALLOWED_HEADERS.contains(headerName.toLowerCase())) {
if (!DISALLOWED_HEADERS.contains(headerName.toLowerCase(Locale.ROOT))) {
for (String headerValue : headerValues) {
builder.header(headerName, headerValue);
}

View File

@ -57,7 +57,7 @@ class JdkClientHttpResponse implements ClientHttpResponse {
private static HttpHeaders adaptHeaders(HttpResponse<?> response) {
Map<String, List<String>> rawHeaders = response.headers().map();
Map<String, List<String>> map = new LinkedCaseInsensitiveMap<>(rawHeaders.size(), Locale.ENGLISH);
Map<String, List<String>> map = new LinkedCaseInsensitiveMap<>(rawHeaders.size(), Locale.ROOT);
MultiValueMap<String, String> multiValueMap = CollectionUtils.toMultiValueMap(map);
multiValueMap.putAll(rawHeaders);
return HttpHeaders.readOnlyHttpHeaders(multiValueMap);

View File

@ -17,6 +17,7 @@
package org.springframework.http.client.observation;
import java.io.IOException;
import java.util.Locale;
import java.util.regex.Pattern;
import io.micrometer.common.KeyValue;
@ -89,7 +90,7 @@ public class DefaultClientRequestObservationConvention implements ClientRequestO
@Nullable
public String getContextualName(ClientRequestObservationContext context) {
ClientHttpRequest request = context.getCarrier();
return (request != null ? "http " + request.getMethod().name().toLowerCase() : null);
return (request != null ? "http " + request.getMethod().name().toLowerCase(Locale.ROOT) : null);
}
@Override

View File

@ -68,7 +68,7 @@ class JdkClientHttpResponse extends AbstractClientHttpResponse {
private static HttpHeaders adaptHeaders(HttpResponse<Flow.Publisher<List<ByteBuffer>>> response) {
Map<String, List<String>> rawHeaders = response.headers().map();
Map<String, List<String>> map = new LinkedCaseInsensitiveMap<>(rawHeaders.size(), Locale.ENGLISH);
Map<String, List<String>> map = new LinkedCaseInsensitiveMap<>(rawHeaders.size(), Locale.ROOT);
MultiValueMap<String, String> multiValueMap = CollectionUtils.toMultiValueMap(map);
multiValueMap.putAll(rawHeaders);
return HttpHeaders.readOnlyHttpHeaders(multiValueMap);

View File

@ -1,5 +1,5 @@
/*
* Copyright 2002-2023 the original author or authors.
* Copyright 2002-2024 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.
@ -16,6 +16,7 @@
package org.springframework.http.server.observation;
import java.util.Locale;
import java.util.Set;
import java.util.stream.Collectors;
import java.util.stream.Stream;
@ -89,7 +90,7 @@ public class DefaultServerRequestObservationConvention implements ServerRequestO
@Override
public String getContextualName(ServerRequestObservationContext context) {
String httpMethod = context.getCarrier().getMethod().toLowerCase();
String httpMethod = context.getCarrier().getMethod().toLowerCase(Locale.ROOT);
if (context.getPathPattern() != null) {
return "http " + httpMethod + " " + context.getPathPattern();
}

View File

@ -112,7 +112,7 @@ class ServletServerHttpRequest extends AbstractServerHttpRequest {
private static MultiValueMap<String, String> createDefaultHttpHeaders(HttpServletRequest request) {
MultiValueMap<String, String> 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(); ) {

View File

@ -1,5 +1,5 @@
/*
* Copyright 2002-2023 the original author or authors.
* Copyright 2002-2024 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.
@ -16,6 +16,7 @@
package org.springframework.http.server.reactive.observation;
import java.util.Locale;
import java.util.Set;
import io.micrometer.common.KeyValue;
@ -87,7 +88,7 @@ public class DefaultServerRequestObservationConvention implements ServerRequestO
@Override
public String getContextualName(ServerRequestObservationContext context) {
String httpMethod = context.getCarrier().getMethod().name().toLowerCase();
String httpMethod = context.getCarrier().getMethod().name().toLowerCase(Locale.ROOT);
if (context.getPathPattern() != null) {
return "http " + httpMethod + " " + context.getPathPattern();
}

View File

@ -1,5 +1,5 @@
/*
* Copyright 2002-2021 the original author or authors.
* Copyright 2002-2024 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.
@ -214,7 +214,7 @@ public class ContentNegotiationManagerFactoryBean
* An alternative to {@link #setMediaTypes} for programmatic registrations.
*/
public void addMediaType(String key, MediaType mediaType) {
this.mediaTypes.put(key.toLowerCase(Locale.ENGLISH), mediaType);
this.mediaTypes.put(key.toLowerCase(Locale.ROOT), mediaType);
}
/**

View File

@ -57,7 +57,7 @@ public class MappingMediaTypeFileExtensionResolver implements MediaTypeFileExten
if (mediaTypes != null) {
Set<String> allFileExtensions = CollectionUtils.newHashSet(mediaTypes.size());
mediaTypes.forEach((extension, mediaType) -> {
String lowerCaseExtension = extension.toLowerCase(Locale.ENGLISH);
String lowerCaseExtension = extension.toLowerCase(Locale.ROOT);
this.mediaTypes.put(lowerCaseExtension, mediaType);
addFileExtension(mediaType, lowerCaseExtension);
allFileExtensions.add(lowerCaseExtension);
@ -109,7 +109,7 @@ public class MappingMediaTypeFileExtensionResolver implements MediaTypeFileExten
*/
@Nullable
protected MediaType lookupMediaType(String extension) {
return this.mediaTypes.get(extension.toLowerCase(Locale.ENGLISH));
return this.mediaTypes.get(extension.toLowerCase(Locale.ROOT));
}
}

View File

@ -1,5 +1,5 @@
/*
* Copyright 2002-2020 the original author or authors.
* Copyright 2002-2024 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.
@ -99,7 +99,7 @@ public class PathExtensionContentNegotiationStrategy extends AbstractMappingCont
// Ignore LOOKUP_PATH attribute, use our own "fixed" UrlPathHelper with decoding off
String path = this.urlPathHelper.getLookupPathForRequest(request);
String extension = UriUtils.extractFileExtension(path);
return (StringUtils.hasText(extension) ? extension.toLowerCase(Locale.ENGLISH) : null);
return (StringUtils.hasText(extension) ? extension.toLowerCase(Locale.ROOT) : null);
}
/**

View File

@ -105,7 +105,7 @@ public class RestClientResponseException extends RestClientException {
private static HttpHeaders copyHeaders(@Nullable HttpHeaders headers) {
if (headers != null) {
MultiValueMap<String, String> result =
CollectionUtils.toMultiValueMap(new LinkedCaseInsensitiveMap<>(headers.size(), Locale.ENGLISH));
CollectionUtils.toMultiValueMap(new LinkedCaseInsensitiveMap<>(headers.size(), Locale.ROOT));
headers.forEach((name, values) -> values.forEach(value -> result.add(name, value)));
return HttpHeaders.readOnlyHttpHeaders(result);
}

View File

@ -82,7 +82,7 @@ public class ForwardedHeaderFilter extends OncePerRequestFilter {
private static final Log logger = LogFactory.getLog(ForwardedHeaderFilter.class);
private static final Set<String> FORWARDED_HEADER_NAMES =
Collections.newSetFromMap(new LinkedCaseInsensitiveMap<>(10, Locale.ENGLISH));
Collections.newSetFromMap(new LinkedCaseInsensitiveMap<>(10, Locale.ROOT));
static {
FORWARDED_HEADER_NAMES.add("Forwarded");
@ -204,7 +204,7 @@ public class ForwardedHeaderFilter extends OncePerRequestFilter {
}
private static Set<String> headerNames(HttpServletRequest request) {
Set<String> headerNames = Collections.newSetFromMap(new LinkedCaseInsensitiveMap<>(Locale.ENGLISH));
Set<String> headerNames = Collections.newSetFromMap(new LinkedCaseInsensitiveMap<>(Locale.ROOT));
Enumeration<String> names = request.getHeaderNames();
while (names.hasMoreElements()) {
String name = names.nextElement();

View File

@ -1,5 +1,5 @@
/*
* Copyright 2002-2021 the original author or authors.
* Copyright 2002-2024 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.
@ -81,7 +81,7 @@ public class HiddenHttpMethodFilter extends OncePerRequestFilter {
if ("POST".equals(request.getMethod()) && request.getAttribute(WebUtils.ERROR_EXCEPTION_ATTRIBUTE) == null) {
String paramValue = request.getParameter(this.methodParam);
if (StringUtils.hasLength(paramValue)) {
String method = paramValue.toUpperCase(Locale.ENGLISH);
String method = paramValue.toUpperCase(Locale.ROOT);
if (ALLOWED_METHODS.contains(method)) {
requestToUse = new HttpMethodRequestWrapper(request, method);
}

View File

@ -1,5 +1,5 @@
/*
* Copyright 2002-2021 the original author or authors.
* Copyright 2002-2024 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.
@ -88,7 +88,7 @@ public class HiddenHttpMethodFilter implements WebFilter {
}
private ServerWebExchange mapExchange(ServerWebExchange exchange, String methodParamValue) {
HttpMethod httpMethod = HttpMethod.valueOf(methodParamValue.toUpperCase(Locale.ENGLISH));
HttpMethod httpMethod = HttpMethod.valueOf(methodParamValue.toUpperCase(Locale.ROOT));
if (ALLOWED_METHODS.contains(httpMethod)) {
return exchange.mutate().request(builder -> builder.method(httpMethod)).build();
}

View File

@ -1,5 +1,5 @@
/*
* Copyright 2002-2023 the original author or authors.
* Copyright 2002-2024 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.
@ -19,6 +19,7 @@ package org.springframework.web.multipart.support;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
import java.util.Locale;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.Part;
@ -71,7 +72,7 @@ public final class MultipartResolutionDelegate {
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) {

View File

@ -28,6 +28,7 @@ import java.util.Collections;
import java.util.Enumeration;
import java.util.LinkedHashMap;
import java.util.LinkedHashSet;
import java.util.Locale;
import java.util.Map;
import java.util.Set;
@ -118,7 +119,7 @@ public class StandardMultipartHttpServletRequest extends AbstractMultipartHttpSe
do {
String msg = cause.getMessage();
if (msg != null) {
msg = msg.toLowerCase();
msg = msg.toLowerCase(Locale.ROOT);
if ((msg.contains("exceed") && (msg.contains("size") || msg.contains("length"))) ||
(msg.contains("request") && (msg.contains("big") || msg.contains("large")))) {
throw new MaxUploadSizeExceededException(-1, ex);

View File

@ -61,7 +61,7 @@ import org.springframework.web.util.UriComponents;
public class ForwardedHeaderTransformer implements Function<ServerHttpRequest, ServerHttpRequest> {
static final Set<String> FORWARDED_HEADER_NAMES =
Collections.newSetFromMap(new LinkedCaseInsensitiveMap<>(10, Locale.ENGLISH));
Collections.newSetFromMap(new LinkedCaseInsensitiveMap<>(10, Locale.ROOT));
static {
FORWARDED_HEADER_NAMES.add("Forwarded");

View File

@ -16,6 +16,7 @@
package org.springframework.web.util;
import java.util.Locale;
import java.util.Set;
import org.apache.commons.logging.Log;
@ -84,7 +85,7 @@ public class DisconnectedClientHelper {
public static boolean isClientDisconnectedException(Throwable ex) {
String message = NestedExceptionUtils.getMostSpecificCause(ex).getMessage();
if (message != null) {
String text = message.toLowerCase();
String text = message.toLowerCase(Locale.ROOT);
for (String phrase : EXCEPTION_PHRASES) {
if (text.contains(phrase)) {
return true;

View File

@ -1,5 +1,5 @@
/*
* Copyright 2002-2023 the original author or authors.
* Copyright 2002-2024 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.
@ -18,6 +18,7 @@ package org.springframework.web.util;
import java.net.URLDecoder;
import java.nio.charset.UnsupportedCharsetException;
import java.util.Locale;
import java.util.Map;
import java.util.Properties;
@ -629,7 +630,7 @@ public class UrlPathHelper {
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;
}

View File

@ -169,7 +169,7 @@ abstract class AbstractHttpRequestFactoryTests extends AbstractMockWebServerTest
try (ClientHttpResponse response = request.execute()) {
assertThat(response.getStatusCode()).as("Invalid response status").isEqualTo(HttpStatus.OK);
assertThat(request.getMethod().name()).as("Invalid method").isEqualTo(path.toUpperCase(Locale.ENGLISH));
assertThat(request.getMethod().name()).as("Invalid method").isEqualTo(path.toUpperCase(Locale.ROOT));
}
}

View File

@ -1,5 +1,5 @@
/*
* Copyright 2002-2017 the original author or authors.
* Copyright 2002-2024 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.
@ -51,7 +51,7 @@ public class ParameterContentTypeResolver implements RequestedContentTypeResolve
}
private static String formatKey(String key) {
return key.toLowerCase(Locale.ENGLISH);
return key.toLowerCase(Locale.ROOT);
}

View File

@ -17,6 +17,7 @@
package org.springframework.web.reactive.function.client;
import java.io.IOException;
import java.util.Locale;
import java.util.regex.Pattern;
import io.micrometer.common.KeyValue;
@ -92,7 +93,7 @@ public class DefaultClientRequestObservationConvention implements ClientRequestO
@Nullable
public String getContextualName(ClientRequestObservationContext context) {
ClientRequest request = context.getRequest();
return (request != null ? "http " + request.method().name().toLowerCase() : null);
return (request != null ? "http " + request.method().name().toLowerCase(Locale.ROOT) : null);
}
@Override

View File

@ -1,5 +1,5 @@
/*
* Copyright 2002-2019 the original author or authors.
* Copyright 2002-2024 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.
@ -20,6 +20,7 @@ import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import java.util.Locale;
import java.util.stream.Collectors;
import reactor.core.publisher.Mono;
@ -140,7 +141,7 @@ public class CachingResourceResolver extends AbstractResourceResolver {
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()

View File

@ -1,5 +1,5 @@
/*
* Copyright 2002-2023 the original author or authors.
* Copyright 2002-2024 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.
@ -28,6 +28,7 @@ import java.util.Arrays;
import java.util.Collections;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Locale;
import java.util.Map;
import reactor.core.publisher.Mono;
@ -169,7 +170,7 @@ public class EncodedResourceResolver extends AbstractResourceResolver {
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) {

View File

@ -339,7 +339,7 @@ public class ResourceWebHandler implements WebHandler, InitializingBean {
this.mediaTypes = new HashMap<>(mediaTypes.size());
}
mediaTypes.forEach((ext, type) ->
this.mediaTypes.put(ext.toLowerCase(Locale.ENGLISH), type));
this.mediaTypes.put(ext.toLowerCase(Locale.ROOT), type));
}
/**
@ -532,7 +532,7 @@ public class ResourceWebHandler implements WebHandler, InitializingBean {
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) {

View File

@ -1,5 +1,5 @@
/*
* Copyright 2002-2018 the original author or authors.
* Copyright 2002-2024 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.
@ -16,6 +16,8 @@
package org.springframework.web.reactive.result.condition;
import java.util.Locale;
import org.springframework.lang.Nullable;
import org.springframework.util.ObjectUtils;
import org.springframework.web.server.ServerWebExchange;
@ -106,7 +108,7 @@ abstract class AbstractNameValueExpression<T> implements NameValueExpression<T>
@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;

View File

@ -1,5 +1,5 @@
/*
* Copyright 2002-2018 the original author or authors.
* Copyright 2002-2024 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.
@ -16,6 +16,8 @@
package org.springframework.web.servlet.mvc.condition;
import java.util.Locale;
import jakarta.servlet.http.HttpServletRequest;
import org.springframework.lang.Nullable;
@ -108,7 +110,7 @@ abstract class AbstractNameValueExpression<T> implements NameValueExpression<T>
@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;

View File

@ -532,7 +532,7 @@ public abstract class AbstractMessageConverterMethodProcessor extends AbstractMe
if (!StringUtils.hasText(extension)) {
return true;
}
extension = extension.toLowerCase(Locale.ENGLISH);
extension = extension.toLowerCase(Locale.ROOT);
if (this.safeExtensions.contains(extension)) {
return true;
}

View File

@ -1,5 +1,5 @@
/*
* Copyright 2002-2023 the original author or authors.
* Copyright 2002-2024 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.
@ -20,6 +20,7 @@ import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import java.util.Locale;
import java.util.stream.Collectors;
import jakarta.servlet.http.HttpServletRequest;
@ -147,7 +148,7 @@ public class CachingResourceResolver extends AbstractResourceResolver {
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()

View File

@ -28,6 +28,7 @@ import java.util.Arrays;
import java.util.Collections;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Locale;
import java.util.Map;
import jakarta.servlet.http.HttpServletRequest;
@ -166,7 +167,7 @@ public class EncodedResourceResolver extends AbstractResourceResolver {
@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) {

View File

@ -318,7 +318,7 @@ public class ResourceHttpRequestHandler extends WebContentGenerator
*/
public void setMediaTypes(Map<String, MediaType> mediaTypes) {
mediaTypes.forEach((ext, mediaType) ->
this.mediaTypes.put(ext.toLowerCase(Locale.ENGLISH), mediaType));
this.mediaTypes.put(ext.toLowerCase(Locale.ROOT), mediaType));
}
/**
@ -708,7 +708,7 @@ public class ResourceHttpRequestHandler extends WebContentGenerator
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<MediaType> mediaTypes = MediaTypeFactory.getMediaTypes(filename);

View File

@ -20,6 +20,7 @@ import java.io.IOException;
import java.io.InputStream;
import java.io.Reader;
import java.util.Enumeration;
import java.util.Locale;
import java.util.Map;
import java.util.Properties;
@ -417,7 +418,7 @@ public class XsltView extends AbstractUrlBasedView {
}
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;
}
}

View File

@ -1,5 +1,5 @@
/*
* Copyright 2002-2022 the original author or authors.
* Copyright 2002-2024 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.
@ -72,7 +72,7 @@ public class WebSocketExtension {
Assert.hasLength(name, "Extension name must not be empty");
this.name = name;
if (!CollectionUtils.isEmpty(parameters)) {
Map<String, String> map = new LinkedCaseInsensitiveMap<>(parameters.size(), Locale.ENGLISH);
Map<String, String> map = new LinkedCaseInsensitiveMap<>(parameters.size(), Locale.ROOT);
map.putAll(parameters);
this.parameters = Collections.unmodifiableMap(map);
}

View File

@ -1,5 +1,5 @@
/*
* Copyright 2002-2022 the original author or authors.
* Copyright 2002-2024 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.
@ -42,7 +42,7 @@ public class StandardToWebSocketExtensionAdapter extends WebSocketExtension {
private static Map<String, String> initParameters(Extension extension) {
List<Extension.Parameter> parameters = extension.getParameters();
Map<String, String> result = new LinkedCaseInsensitiveMap<>(parameters.size(), Locale.ENGLISH);
Map<String, String> result = new LinkedCaseInsensitiveMap<>(parameters.size(), Locale.ROOT);
for (Extension.Parameter parameter : parameters) {
result.put(parameter.getName(), parameter.getValue());
}

View File

@ -203,7 +203,7 @@ public class StandardWebSocketClient extends AbstractWebSocketClient {
private static int getPort(URI uri) {
if (uri.getPort() == -1) {
String scheme = uri.getScheme().toLowerCase(Locale.ENGLISH);
String scheme = uri.getScheme().toLowerCase(Locale.ROOT);
return ("wss".equals(scheme) ? 443 : 80);
}
return uri.getPort();