Merge branch '3.3.x'

Closes gh-42736
This commit is contained in:
Moritz Halbritter
2024-10-17 13:38:45 +02:00
37 changed files with 229 additions and 38 deletions

View File

@@ -191,7 +191,8 @@ public class AntoraAsciidocAttributes {
};
try (InputStream in = getClass().getResourceAsStream("antora-asciidoc-attributes.properties")) {
properties.load(in);
} catch (IOException ex) {
}
catch (IOException ex) {
throw new UncheckedIOException(ex);
}
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2022-2024 the original author or authors.
* Copyright 2012-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.
@@ -89,7 +89,8 @@ public abstract class ArchitectureCheck extends DefaultTask {
noClassesShouldCallStepVerifierStepVerifyComplete(),
noClassesShouldConfigureDefaultStepVerifierTimeout(), noClassesShouldCallCollectorsToList(),
noClassesShouldCallURLEncoderWithStringEncoding(), noClassesShouldCallURLDecoderWithStringEncoding(),
noClassesShouldLoadResourcesUsingResourceUtils());
noClassesShouldLoadResourcesUsingResourceUtils(), noClassesShouldCallStringToUpperCaseWithoutLocale(),
noClassesShouldCallStringToLowerCaseWithoutLocale());
getRules().addAll(getProhibitObjectsRequireNonNull()
.map((prohibit) -> prohibit ? noClassesShouldCallObjectsRequireNonNull() : Collections.emptyList()));
getRuleDescriptions().set(getRules().map((rules) -> rules.stream().map(ArchRule::getDescription).toList()));
@@ -191,6 +192,20 @@ public abstract class ArchitectureCheck extends DefaultTask {
};
}
private ArchRule noClassesShouldCallStringToLowerCaseWithoutLocale() {
return ArchRuleDefinition.noClasses()
.should()
.callMethod(String.class, "toLowerCase")
.because("String.toLowerCase(Locale.ROOT) should be used instead");
}
private ArchRule noClassesShouldCallStringToUpperCaseWithoutLocale() {
return ArchRuleDefinition.noClasses()
.should()
.callMethod(String.class, "toUpperCase")
.because("String.toUpperCase(Locale.ROOT) should be used instead");
}
private ArchRule noClassesShouldCallStepVerifierStepVerifyComplete() {
return ArchRuleDefinition.noClasses()
.should()

View File

@@ -16,6 +16,8 @@
package org.springframework.boot.build.artifacts;
import java.util.Locale;
import org.gradle.api.Project;
/**
@@ -37,7 +39,7 @@ public final class ArtifactRelease {
}
public String getType() {
return this.type.toString().toLowerCase();
return this.type.toString().toLowerCase(Locale.ROOT);
}
public String getDownloadRepo() {

View File

@@ -102,7 +102,7 @@ public class Library {
}
private static String generateLinkRootName(String name) {
return name.replace("-", "").replace(" ", "-").toLowerCase();
return name.replace("-", "").replace(" ", "-").toLowerCase(Locale.ROOT);
}
public String getName() {

View File

@@ -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);
}
}

View File

@@ -163,6 +163,42 @@ class ArchitectureCheckTests {
});
}
@Test
void whenClassCallsStringToUpperCaseWithoutLocaleFailsAndWritesReport() throws Exception {
prepareTask("string/toUpperCase", (architectureCheck) -> {
assertThatExceptionOfType(GradleException.class).isThrownBy(architectureCheck::checkArchitecture);
assertThat(failureReport(architectureCheck)).isNotEmpty()
.content()
.contains("because String.toUpperCase(Locale.ROOT) should be used instead");
});
}
@Test
void whenClassCallsStringToLowerCaseWithoutLocaleFailsAndWritesReport() throws Exception {
prepareTask("string/toLowerCase", (architectureCheck) -> {
assertThatExceptionOfType(GradleException.class).isThrownBy(architectureCheck::checkArchitecture);
assertThat(failureReport(architectureCheck)).isNotEmpty()
.content()
.contains("because String.toLowerCase(Locale.ROOT) should be used instead");
});
}
@Test
void whenClassCallsStringToLowerCaseWithLocaleShouldNotFail() throws Exception {
prepareTask("string/toLowerCaseWithLocale", (architectureCheck) -> {
architectureCheck.checkArchitecture();
assertThat(failureReport(architectureCheck)).isEmpty();
});
}
@Test
void whenClassCallsStringToUpperCaseWithLocaleShouldNotFail() throws Exception {
prepareTask("string/toUpperCaseWithLocale", (architectureCheck) -> {
architectureCheck.checkArchitecture();
assertThat(failureReport(architectureCheck)).isEmpty();
});
}
private void prepareTask(String classes, Callback<ArchitectureCheck> callback) throws Exception {
File projectDir = new File(this.temp, "project");
projectDir.mkdirs();

View File

@@ -0,0 +1,26 @@
/*
* Copyright 2012-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.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.boot.build.architecture.string.toLowerCase;
class ToLowerCase {
void exampleMethod() {
String test = "Object must not be null";
System.out.println(test.toLowerCase());
}
}

View File

@@ -0,0 +1,28 @@
/*
* Copyright 2012-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.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.boot.build.architecture.string.toLowerCaseWithLocale;
import java.util.Locale;
class ToLowerCaseWithLocale {
void exampleMethod() {
String test = "Object must not be null";
System.out.println(test.toLowerCase(Locale.ENGLISH));
}
}

View File

@@ -0,0 +1,26 @@
/*
* Copyright 2012-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.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.boot.build.architecture.string.toUpperCase;
class ToUpperCase {
void exampleMethod() {
String test = "Object must not be null";
System.out.println(test.toUpperCase());
}
}

View File

@@ -0,0 +1,28 @@
/*
* Copyright 2012-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.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.boot.build.architecture.string.toUpperCaseWithLocale;
import java.util.Locale;
class ToUpperCaseWithLocale {
void exampleMethod() {
String test = "Object must not be null";
System.out.println(test.toUpperCase(Locale.ROOT));
}
}

View File

@@ -21,6 +21,7 @@ import java.util.Collection;
import java.util.EnumSet;
import java.util.LinkedHashSet;
import java.util.List;
import java.util.Locale;
import java.util.Map;
import java.util.Optional;
import java.util.Set;
@@ -206,7 +207,7 @@ class OnAvailableEndpointCondition extends SpringBootCondition {
StandardExposureOutcomeContributor(Environment environment, EndpointExposure exposure) {
this.exposure = exposure;
String name = exposure.name().toLowerCase().replace('_', '-');
String name = exposure.name().toLowerCase(Locale.ROOT).replace('_', '-');
this.property = "management.endpoints." + name + ".exposure";
this.filter = new IncludeExcludeEndpointFilter<>(ExposableEndpoint.class, environment, this.property,
exposure.getDefaultIncludes());

View File

@@ -16,6 +16,8 @@
package org.springframework.boot.actuate.autoconfigure.tracing.otlp;
import java.util.Locale;
import io.opentelemetry.exporter.otlp.http.trace.OtlpHttpSpanExporter;
import io.opentelemetry.exporter.otlp.http.trace.OtlpHttpSpanExporterBuilder;
import io.opentelemetry.exporter.otlp.trace.OtlpGrpcSpanExporter;
@@ -85,7 +87,7 @@ class OtlpTracingConfigurations {
.setEndpoint(connectionDetails.getUrl(Transport.HTTP))
.setTimeout(properties.getTimeout())
.setConnectTimeout(properties.getConnectTimeout())
.setCompression(properties.getCompression().name().toLowerCase());
.setCompression(properties.getCompression().name().toLowerCase(Locale.ROOT));
properties.getHeaders().forEach(builder::addHeader);
return builder.build();
}
@@ -98,7 +100,7 @@ class OtlpTracingConfigurations {
.setEndpoint(connectionDetails.getUrl(Transport.GRPC))
.setTimeout(properties.getTimeout())
.setConnectTimeout(properties.getConnectTimeout())
.setCompression(properties.getCompression().name().toLowerCase());
.setCompression(properties.getCompression().name().toLowerCase(Locale.ROOT));
properties.getHeaders().forEach(builder::addHeader);
return builder.build();
}

View File

@@ -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);
}
});

View File

@@ -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));
}
}

View File

@@ -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));
}
}

View File

@@ -19,6 +19,7 @@ package org.springframework.boot.autoconfigure.hazelcast;
import java.io.IOException;
import java.io.UncheckedIOException;
import java.net.URL;
import java.util.Locale;
import com.hazelcast.client.config.ClientConfig;
import com.hazelcast.client.config.XmlClientConfigBuilder;
@@ -54,7 +55,7 @@ class PropertiesHazelcastConnectionDetails implements HazelcastConnectionDetails
private ClientConfig loadClientConfig(Resource configLocation) {
try {
URL configUrl = configLocation.getURL();
String configFileName = configUrl.getPath().toLowerCase();
String configFileName = configUrl.getPath().toLowerCase(Locale.ROOT);
return (!isYaml(configFileName)) ? new XmlClientConfigBuilder(configUrl).build()
: new YamlClientConfigBuilder(configUrl).build();
}

View File

@@ -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;
@@ -124,7 +125,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);
@@ -133,7 +134,7 @@ final class OAuth2AuthorizationServerPropertiesMapper {
}
private SignatureAlgorithm signatureAlgorithm(String signatureAlgorithm) {
return SignatureAlgorithm.from(signatureAlgorithm.toUpperCase());
return SignatureAlgorithm.from(signatureAlgorithm.toUpperCase(Locale.ROOT));
}
}

View File

@@ -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();
}

View File

@@ -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);

View File

@@ -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);

View File

@@ -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()));
}
}

View File

@@ -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";
}
}

View File

@@ -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) {

View File

@@ -638,7 +638,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),

View File

@@ -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");
}

View File

@@ -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");
}
}

View File

@@ -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;
}

View File

@@ -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) -> {
});
}

View File

@@ -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 : "");

View 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) {

View File

@@ -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));
}

View File

@@ -20,6 +20,7 @@ import java.util.Arrays;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Locale;
import java.util.Map;
import org.apache.logging.log4j.Level;
@@ -56,7 +57,7 @@ public final class ColorConverter extends LogEventPatternConverter {
Map<String, AnsiElement> ansiElements = new HashMap<>();
Arrays.stream(AnsiColor.values())
.filter((color) -> color != AnsiColor.DEFAULT)
.forEach((color) -> ansiElements.put(color.name().toLowerCase(), color));
.forEach((color) -> ansiElements.put(color.name().toLowerCase(Locale.ROOT), color));
ansiElements.put("faint", AnsiStyle.FAINT);
ELEMENTS = Collections.unmodifiableMap(ansiElements);
}

View File

@@ -19,6 +19,7 @@ package org.springframework.boot.logging.logback;
import java.util.Arrays;
import java.util.Collections;
import java.util.HashMap;
import java.util.Locale;
import java.util.Map;
import ch.qos.logback.classic.Level;
@@ -46,7 +47,7 @@ public class ColorConverter extends CompositeConverter<ILoggingEvent> {
Map<String, AnsiElement> ansiElements = new HashMap<>();
Arrays.stream(AnsiColor.values())
.filter((color) -> color != AnsiColor.DEFAULT)
.forEach((color) -> ansiElements.put(color.name().toLowerCase(), color));
.forEach((color) -> ansiElements.put(color.name().toLowerCase(Locale.ROOT), color));
ansiElements.put("faint", AnsiStyle.FAINT);
ELEMENTS = Collections.unmodifiableMap(ansiElements);
}

View File

@@ -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);
}
});

View File

@@ -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;
}

View File

@@ -20,6 +20,7 @@ import java.util.ArrayList;
import java.util.Collections;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Locale;
import java.util.Map;
import java.util.Set;
import java.util.function.Function;
@@ -743,14 +744,14 @@ class JsonWriterTests {
@Test
void whenInstanceOfWhenInstanceMatches() {
ValueProcessor<Object> processor = ValueProcessor.of((value) -> value.toString().toUpperCase())
ValueProcessor<Object> processor = ValueProcessor.of((value) -> value.toString().toUpperCase(Locale.ROOT))
.whenInstanceOf(String.class);
assertThat(processor.processValue(null, "test")).hasToString("TEST");
}
@Test
void whenInstanceOfWhenInstanceDoesNotMatch() {
ValueProcessor<Object> processor = ValueProcessor.of((value) -> value.toString().toUpperCase())
ValueProcessor<Object> processor = ValueProcessor.of((value) -> value.toString().toUpperCase(Locale.ROOT))
.whenInstanceOf(String.class);
assertThat(processor.processValue(null, new StringBuilder("test"))).hasToString("test");
}

View File

@@ -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()) {