diff --git a/spring-test/src/main/java/org/springframework/test/context/junit/jupiter/AbstractExpressionEvaluatingCondition.java b/spring-test/src/main/java/org/springframework/test/context/junit/jupiter/AbstractExpressionEvaluatingCondition.java index 7ee63916923a..58ed0b9f4de0 100644 --- a/spring-test/src/main/java/org/springframework/test/context/junit/jupiter/AbstractExpressionEvaluatingCondition.java +++ b/spring-test/src/main/java/org/springframework/test/context/junit/jupiter/AbstractExpressionEvaluatingCondition.java @@ -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 @@ import java.lang.annotation.Annotation; import java.lang.reflect.AnnotatedElement; +import java.util.Locale; import java.util.Optional; import java.util.function.Function; @@ -192,7 +193,7 @@ private boolean evaluateExpression(String expression, boo return b; } else if (result instanceof String str) { - str = str.trim().toLowerCase(); + str = str.trim().toLowerCase(Locale.ROOT); if ("true".equals(str)) { return true; } 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 5a15fd0eb941..8a5a3905fab3 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 @@ -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. @@ -19,6 +19,7 @@ import java.net.URI; import java.util.Collections; import java.util.List; +import java.util.Locale; import java.util.Map; import java.util.Set; import java.util.concurrent.CompletableFuture; @@ -81,7 +82,7 @@ public final CompletableFuture execute(WebSocketHandler webSoc 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 9fcd10e40b0a..fe43f674eef0 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 @@ -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. @@ -23,6 +23,7 @@ import java.util.Arrays; import java.util.Collections; import java.util.List; +import java.util.Locale; import java.util.Map; import org.apache.commons.logging.Log; @@ -154,7 +155,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)); } } @@ -329,10 +330,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 044a4a7bce84..05438ff71866 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 @@ -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.web.socket.sockjs.frame; +import java.util.Locale; + import org.springframework.util.Assert; /** @@ -58,7 +60,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); result.append("0".repeat(Math.max(0, (4 - hex.length())))); result.append(hex); }