Use Locale.ROOT consistently for toLower/toUpperCase

Closes gh-33708
This commit is contained in:
Juergen Hoeller
2024-10-16 13:44:59 +02:00
parent 11d4272ff4
commit c765d03a59
4 changed files with 15 additions and 10 deletions
@@ -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"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@@ -18,6 +18,7 @@ package org.springframework.test.context.junit.jupiter;
import java.lang.annotation.Annotation; import java.lang.annotation.Annotation;
import java.lang.reflect.AnnotatedElement; import java.lang.reflect.AnnotatedElement;
import java.util.Locale;
import java.util.Optional; import java.util.Optional;
import java.util.function.Function; import java.util.function.Function;
@@ -192,7 +193,7 @@ abstract class AbstractExpressionEvaluatingCondition implements ExecutionConditi
return b; return b;
} }
else if (result instanceof String str) { else if (result instanceof String str) {
str = str.trim().toLowerCase(); str = str.trim().toLowerCase(Locale.ROOT);
if ("true".equals(str)) { if ("true".equals(str)) {
return true; return true;
} }
@@ -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"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@@ -19,6 +19,7 @@ package org.springframework.web.socket.client;
import java.net.URI; import java.net.URI;
import java.util.Collections; import java.util.Collections;
import java.util.List; import java.util.List;
import java.util.Locale;
import java.util.Map; import java.util.Map;
import java.util.Set; import java.util.Set;
import java.util.concurrent.CompletableFuture; import java.util.concurrent.CompletableFuture;
@@ -81,7 +82,7 @@ public abstract class AbstractWebSocketClient implements WebSocketClient {
HttpHeaders headersToUse = new HttpHeaders(); HttpHeaders headersToUse = new HttpHeaders();
if (headers != null) { if (headers != null) {
headers.forEach((header, values) -> { headers.forEach((header, values) -> {
if (values != null && !specialHeaders.contains(header.toLowerCase())) { if (values != null && !specialHeaders.contains(header.toLowerCase(Locale.ROOT))) {
headersToUse.put(header, values); headersToUse.put(header, values);
} }
}); });
@@ -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"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@@ -23,6 +23,7 @@ import java.util.ArrayList;
import java.util.Arrays; import java.util.Arrays;
import java.util.Collections; import java.util.Collections;
import java.util.List; import java.util.List;
import java.util.Locale;
import java.util.Map; import java.util.Map;
import org.apache.commons.logging.Log; import org.apache.commons.logging.Log;
@@ -154,7 +155,7 @@ public abstract class AbstractHandshakeHandler implements HandshakeHandler, Life
public void setSupportedProtocols(String... protocols) { public void setSupportedProtocols(String... protocols) {
this.supportedProtocols.clear(); this.supportedProtocols.clear();
for (String protocol : protocols) { for (String protocol : protocols) {
this.supportedProtocols.add(protocol.toLowerCase()); this.supportedProtocols.add(protocol.toLowerCase(Locale.ROOT));
} }
} }
@@ -329,10 +330,10 @@ public abstract class AbstractHandshakeHandler implements HandshakeHandler, Life
protected String selectProtocol(List<String> requestedProtocols, WebSocketHandler webSocketHandler) { protected String selectProtocol(List<String> requestedProtocols, WebSocketHandler webSocketHandler) {
List<String> handlerProtocols = determineHandlerSupportedProtocols(webSocketHandler); List<String> handlerProtocols = determineHandlerSupportedProtocols(webSocketHandler);
for (String protocol : requestedProtocols) { for (String protocol : requestedProtocols) {
if (handlerProtocols.contains(protocol.toLowerCase())) { if (handlerProtocols.contains(protocol.toLowerCase(Locale.ROOT))) {
return protocol; return protocol;
} }
if (this.supportedProtocols.contains(protocol.toLowerCase())) { if (this.supportedProtocols.contains(protocol.toLowerCase(Locale.ROOT))) {
return protocol; return protocol;
} }
} }
@@ -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"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@@ -16,6 +16,8 @@
package org.springframework.web.socket.sockjs.frame; package org.springframework.web.socket.sockjs.frame;
import java.util.Locale;
import org.springframework.util.Assert; import org.springframework.util.Assert;
/** /**
@@ -58,7 +60,7 @@ public abstract class AbstractSockJsMessageCodec implements SockJsMessageCodec {
for (char c : characters) { for (char c : characters) {
if (isSockJsSpecialChar(c)) { if (isSockJsSpecialChar(c)) {
result.append('\\').append('u'); result.append('\\').append('u');
String hex = Integer.toHexString(c).toLowerCase(); String hex = Integer.toHexString(c).toLowerCase(Locale.ROOT);
result.append("0".repeat(Math.max(0, (4 - hex.length())))); result.append("0".repeat(Math.max(0, (4 - hex.length()))));
result.append(hex); result.append(hex);
} }