Skip to content

Commit c765d03

Browse files
committed
Use Locale.ROOT consistently for toLower/toUpperCase
Closes gh-33708
1 parent 11d4272 commit c765d03

File tree

4 files changed

+15
-10
lines changed

4 files changed

+15
-10
lines changed

spring-test/src/main/java/org/springframework/test/context/junit/jupiter/AbstractExpressionEvaluatingCondition.java

+3-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2023 the original author or authors.
2+
* Copyright 2002-2024 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -18,6 +18,7 @@
1818

1919
import java.lang.annotation.Annotation;
2020
import java.lang.reflect.AnnotatedElement;
21+
import java.util.Locale;
2122
import java.util.Optional;
2223
import java.util.function.Function;
2324

@@ -192,7 +193,7 @@ private <A extends Annotation> boolean evaluateExpression(String expression, boo
192193
return b;
193194
}
194195
else if (result instanceof String str) {
195-
str = str.trim().toLowerCase();
196+
str = str.trim().toLowerCase(Locale.ROOT);
196197
if ("true".equals(str)) {
197198
return true;
198199
}

spring-websocket/src/main/java/org/springframework/web/socket/client/AbstractWebSocketClient.java

+3-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2022 the original author or authors.
2+
* Copyright 2002-2024 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -19,6 +19,7 @@
1919
import java.net.URI;
2020
import java.util.Collections;
2121
import java.util.List;
22+
import java.util.Locale;
2223
import java.util.Map;
2324
import java.util.Set;
2425
import java.util.concurrent.CompletableFuture;
@@ -81,7 +82,7 @@ public final CompletableFuture<WebSocketSession> execute(WebSocketHandler webSoc
8182
HttpHeaders headersToUse = new HttpHeaders();
8283
if (headers != null) {
8384
headers.forEach((header, values) -> {
84-
if (values != null && !specialHeaders.contains(header.toLowerCase())) {
85+
if (values != null && !specialHeaders.contains(header.toLowerCase(Locale.ROOT))) {
8586
headersToUse.put(header, values);
8687
}
8788
});

spring-websocket/src/main/java/org/springframework/web/socket/server/support/AbstractHandshakeHandler.java

+5-4
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2023 the original author or authors.
2+
* Copyright 2002-2024 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -23,6 +23,7 @@
2323
import java.util.Arrays;
2424
import java.util.Collections;
2525
import java.util.List;
26+
import java.util.Locale;
2627
import java.util.Map;
2728

2829
import org.apache.commons.logging.Log;
@@ -154,7 +155,7 @@ public RequestUpgradeStrategy getRequestUpgradeStrategy() {
154155
public void setSupportedProtocols(String... protocols) {
155156
this.supportedProtocols.clear();
156157
for (String protocol : protocols) {
157-
this.supportedProtocols.add(protocol.toLowerCase());
158+
this.supportedProtocols.add(protocol.toLowerCase(Locale.ROOT));
158159
}
159160
}
160161

@@ -329,10 +330,10 @@ protected boolean isValidOrigin(ServerHttpRequest request) {
329330
protected String selectProtocol(List<String> requestedProtocols, WebSocketHandler webSocketHandler) {
330331
List<String> handlerProtocols = determineHandlerSupportedProtocols(webSocketHandler);
331332
for (String protocol : requestedProtocols) {
332-
if (handlerProtocols.contains(protocol.toLowerCase())) {
333+
if (handlerProtocols.contains(protocol.toLowerCase(Locale.ROOT))) {
333334
return protocol;
334335
}
335-
if (this.supportedProtocols.contains(protocol.toLowerCase())) {
336+
if (this.supportedProtocols.contains(protocol.toLowerCase(Locale.ROOT))) {
336337
return protocol;
337338
}
338339
}

spring-websocket/src/main/java/org/springframework/web/socket/sockjs/frame/AbstractSockJsMessageCodec.java

+4-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2023 the original author or authors.
2+
* Copyright 2002-2024 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -16,6 +16,8 @@
1616

1717
package org.springframework.web.socket.sockjs.frame;
1818

19+
import java.util.Locale;
20+
1921
import org.springframework.util.Assert;
2022

2123
/**
@@ -58,7 +60,7 @@ private String escapeSockJsSpecialChars(char[] characters) {
5860
for (char c : characters) {
5961
if (isSockJsSpecialChar(c)) {
6062
result.append('\\').append('u');
61-
String hex = Integer.toHexString(c).toLowerCase();
63+
String hex = Integer.toHexString(c).toLowerCase(Locale.ROOT);
6264
result.append("0".repeat(Math.max(0, (4 - hex.length()))));
6365
result.append(hex);
6466
}

0 commit comments

Comments
 (0)