Call String.toLowerCase and .toUppercase with explicit locale
Closes gh-42719
This commit is contained in:
@@ -19,6 +19,7 @@ package org.springframework.boot.build;
|
||||
import java.io.File;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.Locale;
|
||||
import java.util.Map;
|
||||
|
||||
import org.asciidoctor.gradle.jvm.AbstractAsciidoctorTask;
|
||||
@@ -111,7 +112,7 @@ class AsciidoctorConventions {
|
||||
asciidoctorTask.baseDirFollowsSourceDir();
|
||||
createSyncDocumentationSourceTask(project, asciidoctorTask);
|
||||
if (asciidoctorTask instanceof AsciidoctorTask task) {
|
||||
boolean pdf = task.getName().toLowerCase().contains("pdf");
|
||||
boolean pdf = task.getName().toLowerCase(Locale.ROOT).contains("pdf");
|
||||
String backend = (!pdf) ? "spring-html" : "spring-pdf";
|
||||
task.outputOptions((outputOptions) -> outputOptions.backends(backend));
|
||||
}
|
||||
|
||||
@@ -16,6 +16,8 @@
|
||||
|
||||
package org.springframework.boot.build.properties;
|
||||
|
||||
import java.util.Locale;
|
||||
|
||||
/**
|
||||
* The type of build being performed.
|
||||
*
|
||||
@@ -34,7 +36,7 @@ public enum BuildType {
|
||||
COMMERCIAL;
|
||||
|
||||
public String toIdentifier() {
|
||||
return toString().replace("_", "").toLowerCase();
|
||||
return toString().replace("_", "").toLowerCase(Locale.ROOT);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -20,6 +20,7 @@ import java.util.Arrays;
|
||||
import java.util.EnumSet;
|
||||
import java.util.HashSet;
|
||||
import java.util.LinkedHashSet;
|
||||
import java.util.Locale;
|
||||
import java.util.Map;
|
||||
import java.util.Optional;
|
||||
import java.util.Set;
|
||||
@@ -118,7 +119,7 @@ class OnAvailableEndpointCondition extends SpringBootCondition {
|
||||
for (ExposureFilter exposureFilter : exposureFilters) {
|
||||
if (exposuresToCheck.contains(exposureFilter.getExposure()) && exposureFilter.isExposed(endpointId)) {
|
||||
return ConditionOutcome.match(message.because("marked as exposed by a 'management.endpoints."
|
||||
+ exposureFilter.getExposure().name().toLowerCase() + ".exposure' property"));
|
||||
+ exposureFilter.getExposure().name().toLowerCase(Locale.ROOT) + ".exposure' property"));
|
||||
}
|
||||
}
|
||||
return ConditionOutcome.noMatch(message.because("no 'management.endpoints' property marked it as exposed"));
|
||||
@@ -187,7 +188,7 @@ class OnAvailableEndpointCondition extends SpringBootCondition {
|
||||
if (EndpointExposure.CLOUD_FOUNDRY.equals(exposure)) {
|
||||
return "cloud-foundry";
|
||||
}
|
||||
return exposure.name().toLowerCase();
|
||||
return exposure.name().toLowerCase(Locale.ROOT);
|
||||
}
|
||||
|
||||
EndpointExposure getExposure() {
|
||||
|
||||
@@ -16,6 +16,7 @@
|
||||
|
||||
package org.springframework.boot.actuate.autoconfigure.tracing.otlp;
|
||||
|
||||
import java.util.Locale;
|
||||
import java.util.Map.Entry;
|
||||
|
||||
import io.opentelemetry.exporter.otlp.http.trace.OtlpHttpSpanExporter;
|
||||
@@ -78,7 +79,7 @@ class OtlpTracingConfigurations {
|
||||
OtlpHttpSpanExporterBuilder builder = OtlpHttpSpanExporter.builder()
|
||||
.setEndpoint(connectionDetails.getUrl())
|
||||
.setTimeout(properties.getTimeout())
|
||||
.setCompression(properties.getCompression().name().toLowerCase());
|
||||
.setCompression(properties.getCompression().name().toLowerCase(Locale.ROOT));
|
||||
for (Entry<String, String> header : properties.getHeaders().entrySet()) {
|
||||
builder.addHeader(header.getKey(), header.getValue());
|
||||
}
|
||||
|
||||
@@ -25,6 +25,7 @@ import java.util.Collections;
|
||||
import java.util.HashSet;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.function.Supplier;
|
||||
@@ -434,7 +435,7 @@ public final class HttpExchange {
|
||||
|
||||
void excludeUnless(String header, Include exception) {
|
||||
if (!this.includes.contains(exception)) {
|
||||
this.filteredHeaderNames.add(header.toLowerCase());
|
||||
this.filteredHeaderNames.add(header.toLowerCase(Locale.ROOT));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -444,7 +445,7 @@ public final class HttpExchange {
|
||||
}
|
||||
Map<String, List<String>> filtered = new LinkedHashMap<>();
|
||||
headers.forEach((name, value) -> {
|
||||
if (!this.filteredHeaderNames.contains(name.toLowerCase())) {
|
||||
if (!this.filteredHeaderNames.contains(name.toLowerCase(Locale.ROOT))) {
|
||||
filtered.put(name, value);
|
||||
}
|
||||
});
|
||||
|
||||
@@ -17,6 +17,7 @@
|
||||
package org.springframework.boot.actuate.endpoint.annotation;
|
||||
|
||||
import java.lang.reflect.Method;
|
||||
import java.util.Locale;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
@@ -76,7 +77,7 @@ class DiscoveredOperationMethodTests {
|
||||
|
||||
@Override
|
||||
public MimeType getProducedMimeType() {
|
||||
return new MimeType(toString().toLowerCase());
|
||||
return new MimeType(toString().toLowerCase(Locale.ROOT));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -20,6 +20,7 @@ import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.Map;
|
||||
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
@@ -254,7 +255,7 @@ class DiscoveredOperationsFactoryTests {
|
||||
|
||||
@Override
|
||||
public MimeType getProducedMimeType() {
|
||||
return new MimeType(toString().toLowerCase());
|
||||
return new MimeType(toString().toLowerCase(Locale.ROOT));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -18,6 +18,7 @@ package org.springframework.boot.autoconfigure.security.oauth2.server.servlet;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
|
||||
import org.springframework.boot.autoconfigure.security.oauth2.server.servlet.OAuth2AuthorizationServerProperties.Client;
|
||||
import org.springframework.boot.autoconfigure.security.oauth2.server.servlet.OAuth2AuthorizationServerProperties.Registration;
|
||||
@@ -123,7 +124,7 @@ final class OAuth2AuthorizationServerPropertiesMapper {
|
||||
}
|
||||
|
||||
private JwsAlgorithm jwsAlgorithm(String signingAlgorithm) {
|
||||
String name = signingAlgorithm.toUpperCase();
|
||||
String name = signingAlgorithm.toUpperCase(Locale.ROOT);
|
||||
JwsAlgorithm jwsAlgorithm = SignatureAlgorithm.from(name);
|
||||
if (jwsAlgorithm == null) {
|
||||
jwsAlgorithm = MacAlgorithm.from(name);
|
||||
@@ -132,7 +133,7 @@ final class OAuth2AuthorizationServerPropertiesMapper {
|
||||
}
|
||||
|
||||
private SignatureAlgorithm signatureAlgorithm(String signatureAlgorithm) {
|
||||
return SignatureAlgorithm.from(signatureAlgorithm.toUpperCase());
|
||||
return SignatureAlgorithm.from(signatureAlgorithm.toUpperCase(Locale.ROOT));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -24,6 +24,7 @@ import java.net.SocketTimeoutException;
|
||||
import java.security.MessageDigest;
|
||||
import java.security.NoSuchAlgorithmException;
|
||||
import java.util.Base64;
|
||||
import java.util.Locale;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
@@ -81,7 +82,7 @@ class Connection {
|
||||
* @throws Exception in case of errors
|
||||
*/
|
||||
void run() throws Exception {
|
||||
String lowerCaseHeader = this.header.toLowerCase();
|
||||
String lowerCaseHeader = this.header.toLowerCase(Locale.ROOT);
|
||||
if (lowerCaseHeader.contains("upgrade: websocket") && lowerCaseHeader.contains("sec-websocket-version: 13")) {
|
||||
runWebSocket();
|
||||
}
|
||||
|
||||
@@ -27,6 +27,7 @@ import java.time.Duration;
|
||||
import java.util.ArrayList;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
import java.util.concurrent.Callable;
|
||||
@@ -338,7 +339,7 @@ class LiveReloadServerTests {
|
||||
@Override
|
||||
public void beforeRequest(Map<String, List<String>> requestHeaders) {
|
||||
Map<String, List<String>> uppercaseRequestHeaders = new LinkedHashMap<>();
|
||||
requestHeaders.forEach((key, value) -> uppercaseRequestHeaders.put(key.toUpperCase(), value));
|
||||
requestHeaders.forEach((key, value) -> uppercaseRequestHeaders.put(key.toUpperCase(Locale.ROOT), value));
|
||||
requestHeaders.clear();
|
||||
requestHeaders.putAll(uppercaseRequestHeaders);
|
||||
requestHeaders.putAll(this.headers);
|
||||
|
||||
@@ -23,6 +23,7 @@ import java.io.InputStream;
|
||||
import java.io.InputStreamReader;
|
||||
import java.io.UncheckedIOException;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.Locale;
|
||||
import java.util.concurrent.CountDownLatch;
|
||||
import java.util.function.Consumer;
|
||||
|
||||
@@ -42,7 +43,7 @@ class ProcessRunner {
|
||||
|
||||
private static final String USR_LOCAL_BIN = "/usr/local/bin";
|
||||
|
||||
private static final boolean MAC_OS = System.getProperty("os.name").toLowerCase().contains("mac");
|
||||
private static final boolean MAC_OS = System.getProperty("os.name").toLowerCase(Locale.ROOT).contains("mac");
|
||||
|
||||
private static final Log logger = LogFactory.getLog(ProcessRunner.class);
|
||||
|
||||
|
||||
@@ -16,6 +16,8 @@
|
||||
|
||||
package org.springframework.boot.docs.messaging.kafka.streams;
|
||||
|
||||
import java.util.Locale;
|
||||
|
||||
import org.apache.kafka.common.serialization.Serdes;
|
||||
import org.apache.kafka.streams.KeyValue;
|
||||
import org.apache.kafka.streams.StreamsBuilder;
|
||||
@@ -39,7 +41,7 @@ public class MyKafkaStreamsConfiguration {
|
||||
}
|
||||
|
||||
private KeyValue<Integer, String> uppercaseValue(Integer key, String value) {
|
||||
return new KeyValue<>(key, value.toUpperCase());
|
||||
return new KeyValue<>(key, value.toUpperCase(Locale.getDefault()));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -18,6 +18,7 @@ package org.springframework.boot.test.autoconfigure.filter;
|
||||
|
||||
import java.lang.annotation.Annotation;
|
||||
import java.util.Collections;
|
||||
import java.util.Locale;
|
||||
import java.util.Set;
|
||||
|
||||
import org.springframework.context.annotation.ComponentScan.Filter;
|
||||
@@ -45,7 +46,7 @@ public abstract class StandardAnnotationCustomizableTypeExcludeFilter<A extends
|
||||
FilterType[] filterValues = FilterType.values();
|
||||
FILTER_TYPE_ATTRIBUTES = new String[filterValues.length];
|
||||
for (int i = 0; i < filterValues.length; i++) {
|
||||
FILTER_TYPE_ATTRIBUTES[i] = filterValues[i].name().toLowerCase() + "Filters";
|
||||
FILTER_TYPE_ATTRIBUTES[i] = filterValues[i].name().toLowerCase(Locale.ROOT) + "Filters";
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -187,7 +187,7 @@ public final class ImageReference {
|
||||
*/
|
||||
public static ImageReference forJarFile(File jarFile) {
|
||||
String filename = jarFile.getName();
|
||||
Assert.isTrue(filename.toLowerCase().endsWith(".jar"), () -> "File '" + jarFile + "' is not a JAR");
|
||||
Assert.isTrue(filename.toLowerCase(Locale.ROOT).endsWith(".jar"), () -> "File '" + jarFile + "' is not a JAR");
|
||||
filename = filename.substring(0, filename.length() - 4);
|
||||
int firstDot = filename.indexOf('.');
|
||||
if (firstDot == -1) {
|
||||
|
||||
@@ -625,7 +625,7 @@ abstract class AbstractBootArchiveIntegrationTests {
|
||||
|
||||
protected void copyApplication(String name) throws IOException {
|
||||
File output = new File(this.gradleBuild.getProjectDir(),
|
||||
"src/main/java/com/example/" + this.taskName.toLowerCase() + "/" + name);
|
||||
"src/main/java/com/example/" + this.taskName.toLowerCase(Locale.ROOT) + "/" + name);
|
||||
output.mkdirs();
|
||||
FileSystemUtils.copyRecursively(
|
||||
new File("src/test/java/com/example/" + this.taskName.toLowerCase(Locale.ENGLISH) + "/" + name),
|
||||
|
||||
@@ -25,6 +25,7 @@ import java.net.URLConnection;
|
||||
import java.nio.file.Paths;
|
||||
import java.security.CodeSource;
|
||||
import java.security.ProtectionDomain;
|
||||
import java.util.Locale;
|
||||
import java.util.jar.JarFile;
|
||||
|
||||
import org.springframework.util.Assert;
|
||||
@@ -67,7 +68,7 @@ class Context {
|
||||
}
|
||||
|
||||
private boolean isJarOrWar(File jarFile) {
|
||||
String name = jarFile.getName().toLowerCase();
|
||||
String name = jarFile.getName().toLowerCase(Locale.ROOT);
|
||||
return name.endsWith(".jar") || name.endsWith(".war");
|
||||
}
|
||||
|
||||
|
||||
@@ -18,6 +18,7 @@ package org.springframework.boot.loader.tools;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.util.Locale;
|
||||
import java.util.jar.Attributes;
|
||||
import java.util.jar.JarFile;
|
||||
import java.util.jar.Manifest;
|
||||
@@ -88,7 +89,7 @@ public abstract class FileUtils {
|
||||
}
|
||||
|
||||
private static boolean isDigestName(Object name) {
|
||||
return String.valueOf(name).toUpperCase().endsWith("-DIGEST");
|
||||
return String.valueOf(name).toUpperCase(Locale.ROOT).endsWith("-DIGEST");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -16,6 +16,7 @@
|
||||
|
||||
package org.springframework.boot.loader.tools;
|
||||
|
||||
import java.util.Locale;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
import org.springframework.util.Assert;
|
||||
@@ -41,7 +42,7 @@ public class Layer {
|
||||
public Layer(String name) {
|
||||
Assert.hasText(name, "Name must not be empty");
|
||||
Assert.isTrue(PATTERN.matcher(name).matches(), () -> "Malformed layer name '" + name + "'");
|
||||
Assert.isTrue(!name.equalsIgnoreCase("ext") && !name.toLowerCase().startsWith("springboot"),
|
||||
Assert.isTrue(!name.equalsIgnoreCase("ext") && !name.toLowerCase(Locale.ROOT).startsWith("springboot"),
|
||||
() -> "Layer name '" + name + "' is reserved");
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
@@ -19,6 +19,7 @@ package org.springframework.boot.loader.tools;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.nio.file.attribute.FileTime;
|
||||
import java.util.Locale;
|
||||
import java.util.Map;
|
||||
import java.util.jar.JarFile;
|
||||
|
||||
@@ -50,7 +51,7 @@ public class Repackager extends Packager {
|
||||
@Override
|
||||
protected void writeSignatureFileIfNecessary(Map<String, Library> writtenLibraries, AbstractJarWriter writer)
|
||||
throws IOException {
|
||||
if (getSource().getName().toLowerCase().endsWith(".jar") && hasSignedLibrary(writtenLibraries)) {
|
||||
if (getSource().getName().toLowerCase(Locale.ROOT).endsWith(".jar") && hasSignedLibrary(writtenLibraries)) {
|
||||
writer.writeEntry("META-INF/BOOT.SF", (entryWriter) -> {
|
||||
});
|
||||
}
|
||||
|
||||
@@ -18,6 +18,7 @@ package org.springframework.boot.loader.net.protocol.jar;
|
||||
|
||||
import java.lang.ref.SoftReference;
|
||||
import java.net.URL;
|
||||
import java.util.Locale;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
@@ -54,10 +55,10 @@ final class JarFileUrlKey {
|
||||
String host = url.getHost();
|
||||
int port = (url.getPort() != -1) ? url.getPort() : url.getDefaultPort();
|
||||
String file = url.getFile();
|
||||
value.append(protocol.toLowerCase());
|
||||
value.append(protocol.toLowerCase(Locale.ROOT));
|
||||
value.append(":");
|
||||
if (host != null && !host.isEmpty()) {
|
||||
value.append(host.toLowerCase());
|
||||
value.append(host.toLowerCase(Locale.ROOT));
|
||||
value.append((port != -1) ? ":" + port : "");
|
||||
}
|
||||
value.append((file != null) ? file : "");
|
||||
|
||||
@@ -19,6 +19,7 @@ package org.springframework.boot.testsupport.process;
|
||||
import java.lang.reflect.AnnotatedElement;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
@@ -42,7 +43,7 @@ class DisabledIfProcessUnavailableCondition implements ExecutionCondition {
|
||||
|
||||
private static final String USR_LOCAL_BIN = "/usr/local/bin";
|
||||
|
||||
private static final boolean MAC_OS = System.getProperty("os.name").toLowerCase().contains("mac");
|
||||
private static final boolean MAC_OS = System.getProperty("os.name").toLowerCase(Locale.ROOT).contains("mac");
|
||||
|
||||
@Override
|
||||
public ConditionEvaluationResult evaluateExecutionCondition(ExtensionContext context) {
|
||||
|
||||
@@ -26,6 +26,7 @@ import java.nio.file.attribute.BasicFileAttributes;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.EnumSet;
|
||||
import java.util.Locale;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.TreeMap;
|
||||
@@ -212,7 +213,7 @@ public class ConfigTreePropertySource extends EnumerablePropertySource<Path> imp
|
||||
String name = getName(sourceDirectory.relativize(path));
|
||||
if (StringUtils.hasText(name)) {
|
||||
if (options.contains(Option.USE_LOWERCASE_NAMES)) {
|
||||
name = name.toLowerCase();
|
||||
name = name.toLowerCase(Locale.getDefault());
|
||||
}
|
||||
propertyFiles.put(name, new PropertyFile(path, options));
|
||||
}
|
||||
|
||||
@@ -17,6 +17,7 @@
|
||||
package org.springframework.boot.web.server;
|
||||
|
||||
import java.net.BindException;
|
||||
import java.util.Locale;
|
||||
import java.util.function.Consumer;
|
||||
import java.util.function.IntSupplier;
|
||||
|
||||
@@ -81,7 +82,7 @@ public class PortInUseException extends WebServerException {
|
||||
public static void ifPortBindingException(Exception ex, Consumer<BindException> action) {
|
||||
ifCausedBy(ex, BindException.class, (bindException) -> {
|
||||
// bind exception can be also thrown because an address can't be assigned
|
||||
if (bindException.getMessage().toLowerCase().contains("in use")) {
|
||||
if (bindException.getMessage().toLowerCase(Locale.ROOT).contains("in use")) {
|
||||
action.accept(bindException);
|
||||
}
|
||||
});
|
||||
|
||||
@@ -17,6 +17,7 @@
|
||||
package org.springframework.boot.context.properties.source;
|
||||
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.Locale;
|
||||
import java.util.Map;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
@@ -239,7 +240,7 @@ class SpringConfigurationPropertySourceTests {
|
||||
|
||||
@Override
|
||||
public Object getProperty(String name) {
|
||||
name = name.toLowerCase();
|
||||
name = name.toLowerCase(Locale.ROOT);
|
||||
if (!name.startsWith(this.prefix)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -20,6 +20,7 @@ import java.io.File;
|
||||
import java.time.Duration;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.function.Predicate;
|
||||
|
||||
import org.assertj.core.api.Condition;
|
||||
@@ -115,7 +116,7 @@ abstract class AbstractLaunchScriptIntegrationTests {
|
||||
|
||||
private static ImageFromDockerfile createImage(String os, String version) {
|
||||
ImageFromDockerfile image = new ImageFromDockerfile(
|
||||
"spring-boot-launch-script/" + os.toLowerCase() + "-" + version);
|
||||
"spring-boot-launch-script/" + os.toLowerCase(Locale.ROOT) + "-" + version);
|
||||
image.withFileFromFile("Dockerfile",
|
||||
new File("src/dockerTest/resources/conf/" + os + "/" + version + "/Dockerfile"));
|
||||
for (File file : new File("build/downloads/jdk/bellsoft").listFiles()) {
|
||||
|
||||
Reference in New Issue
Block a user