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

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