Merge branch '2.7.x' into 3.0.x

This commit is contained in:
Phillip Webb
2023-02-21 23:15:40 -08:00
1890 changed files with 27173 additions and 21952 deletions

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2012-2022 the original author or authors.
* Copyright 2012-2023 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.
@@ -229,7 +229,7 @@ public abstract class Packager {
if (zipEntry != null) {
try (InputStream inputStream = sourceJar.getInputStream(zipEntry)) {
ReachabilityMetadataProperties properties = ReachabilityMetadataProperties
.fromInputStream(inputStream);
.fromInputStream(inputStream);
if (properties.isOverridden()) {
excludes.add(entry.getKey());
}

View File

@@ -105,7 +105,7 @@ abstract class AbstractPackagerTests<P extends Packager> {
execute(packager, NO_LIBRARIES);
Manifest actualManifest = getPackagedManifest();
assertThat(actualManifest.getMainAttributes().getValue("Main-Class"))
.isEqualTo("org.springframework.boot.loader.JarLauncher");
.isEqualTo("org.springframework.boot.loader.JarLauncher");
assertThat(actualManifest.getMainAttributes().getValue("Start-Class")).isEqualTo("a.b.C");
assertThat(hasPackagedLauncherClasses()).isTrue();
}
@@ -121,7 +121,7 @@ abstract class AbstractPackagerTests<P extends Packager> {
execute(packager, NO_LIBRARIES);
Manifest actualManifest = getPackagedManifest();
assertThat(actualManifest.getMainAttributes().getValue("Main-Class"))
.isEqualTo("org.springframework.boot.loader.JarLauncher");
.isEqualTo("org.springframework.boot.loader.JarLauncher");
assertThat(actualManifest.getMainAttributes().getValue("Start-Class")).isEqualTo("a.b.C");
assertThat(hasPackagedLauncherClasses()).isTrue();
}
@@ -133,7 +133,7 @@ abstract class AbstractPackagerTests<P extends Packager> {
execute(packager, NO_LIBRARIES);
Manifest actualManifest = getPackagedManifest();
assertThat(actualManifest.getMainAttributes().getValue("Main-Class"))
.isEqualTo("org.springframework.boot.loader.JarLauncher");
.isEqualTo("org.springframework.boot.loader.JarLauncher");
assertThat(actualManifest.getMainAttributes().getValue("Start-Class")).isEqualTo("a.b.C");
assertThat(hasPackagedLauncherClasses()).isTrue();
}
@@ -143,8 +143,8 @@ abstract class AbstractPackagerTests<P extends Packager> {
this.testJarFile.addClass("a/b/C.class", ClassWithMainMethod.class);
this.testJarFile.addClass("a/b/D.class", ClassWithMainMethod.class);
P packager = createPackager();
assertThatIllegalStateException().isThrownBy(() -> execute(packager, NO_LIBRARIES)).withMessageContaining(
"Unable to find a single main class from the following candidates [a.b.C, a.b.D]");
assertThatIllegalStateException().isThrownBy(() -> execute(packager, NO_LIBRARIES))
.withMessageContaining("Unable to find a single main class from the following candidates [a.b.C, a.b.D]");
}
@Test
@@ -152,7 +152,7 @@ abstract class AbstractPackagerTests<P extends Packager> {
this.testJarFile.addClass("a/b/C.class", ClassWithoutMainMethod.class);
P packager = createPackager(this.testJarFile.getFile());
assertThatIllegalStateException().isThrownBy(() -> execute(packager, NO_LIBRARIES))
.withMessageContaining("Unable to find main class");
.withMessageContaining("Unable to find main class");
}
@Test
@@ -182,7 +182,7 @@ abstract class AbstractPackagerTests<P extends Packager> {
this.testJarFile.addClass("a/b/C.class", ClassWithMainMethod.class);
P packager = createPackager();
assertThatIllegalArgumentException().isThrownBy(() -> execute(packager, null))
.withMessageContaining("Libraries must not be null");
.withMessageContaining("Libraries must not be null");
}
@Test
@@ -235,7 +235,8 @@ abstract class AbstractPackagerTests<P extends Packager> {
String index = getPackagedEntryContent("BOOT-INF/classpath.idx");
String[] libraries = index.split("\\r?\\n");
List<String> expected = Stream.of(libJarFile1, libJarFile2, libJarFile3)
.map((jar) -> "- \"BOOT-INF/lib/" + jar.getName() + "\"").toList();
.map((jar) -> "- \"BOOT-INF/lib/" + jar.getName() + "\"")
.toList();
assertThat(Arrays.asList(libraries)).containsExactlyElementsOf(expected);
}
@@ -266,7 +267,8 @@ abstract class AbstractPackagerTests<P extends Packager> {
assertThat(hasPackagedEntry("BOOT-INF/classpath.idx")).isTrue();
String classpathIndex = getPackagedEntryContent("BOOT-INF/classpath.idx");
List<String> expectedClasspathIndex = Stream.of(libJarFile1, libJarFile2, libJarFile3)
.map((file) -> "- \"BOOT-INF/lib/" + file.getName() + "\"").toList();
.map((file) -> "- \"BOOT-INF/lib/" + file.getName() + "\"")
.toList();
assertThat(Arrays.asList(classpathIndex.split("\\n"))).containsExactlyElementsOf(expectedClasspathIndex);
assertThat(hasPackagedEntry("BOOT-INF/layers.idx")).isTrue();
String layersIndex = getPackagedEntryContent("BOOT-INF/layers.idx");
@@ -284,7 +286,7 @@ abstract class AbstractPackagerTests<P extends Packager> {
expectedLayers.add("- '0003':");
expectedLayers.add(" - 'BOOT-INF/lib/" + libJarFile3.getName() + "'");
assertThat(layersIndex.split("\\n"))
.containsExactly(expectedLayers.stream().map((s) -> s.replace('\'', '"')).toArray(String[]::new));
.containsExactly(expectedLayers.stream().map((s) -> s.replace('\'', '"')).toArray(String[]::new));
}
@Test
@@ -297,7 +299,7 @@ abstract class AbstractPackagerTests<P extends Packager> {
assertThat(hasPackagedEntry("BOOT-INF/classpath.idx")).isTrue();
String classpathIndex = getPackagedEntryContent("BOOT-INF/classpath.idx");
assertThat(Arrays.asList(classpathIndex.split("\\n")))
.containsExactly("- \"BOOT-INF/lib/spring-boot-jarmode-layertools.jar\"");
.containsExactly("- \"BOOT-INF/lib/spring-boot-jarmode-layertools.jar\"");
assertThat(hasPackagedEntry("BOOT-INF/layers.idx")).isTrue();
String layersIndex = getPackagedEntryContent("BOOT-INF/layers.idx");
List<String> expectedLayers = new ArrayList<>();
@@ -306,7 +308,7 @@ abstract class AbstractPackagerTests<P extends Packager> {
expectedLayers.add(" - 'META-INF/'");
expectedLayers.add(" - 'org/'");
assertThat(layersIndex.split("\\n"))
.containsExactly(expectedLayers.stream().map((s) -> s.replace('\'', '"')).toArray(String[]::new));
.containsExactly(expectedLayers.stream().map((s) -> s.replace('\'', '"')).toArray(String[]::new));
}
@Test
@@ -395,7 +397,7 @@ abstract class AbstractPackagerTests<P extends Packager> {
this.testJarFile.addClass("a/b/C.class", ClassWithoutMainMethod.class);
Packager packager = createPackager();
assertThatIllegalArgumentException().isThrownBy(() -> packager.setLayout(null))
.withMessageContaining("Layout must not be null");
.withMessageContaining("Layout must not be null");
}
@Test
@@ -649,7 +651,7 @@ abstract class AbstractPackagerTests<P extends Packager> {
expected.add("\\Q" + libraryTwo.getName() + "\\E");
expected.add("^/META-INF/native-image/.*");
assertThat(getPackagedEntryContent("META-INF/native-image/argfile"))
.isEqualTo(expected.stream().collect(Collectors.joining("\n")) + "\n");
.isEqualTo(expected.stream().collect(Collectors.joining("\n")) + "\n");
}
private File createLibraryJar() throws IOException {
@@ -675,8 +677,9 @@ abstract class AbstractPackagerTests<P extends Packager> {
protected abstract void execute(P packager, Libraries libraries) throws IOException;
protected Collection<String> getPackagedEntryNames() throws IOException {
return getAllPackagedEntries().stream().map(ZipArchiveEntry::getName)
.collect(Collectors.toCollection(ArrayList::new));
return getAllPackagedEntries().stream()
.map(ZipArchiveEntry::getName)
.collect(Collectors.toCollection(ArrayList::new));
}
protected boolean hasPackagedLauncherClasses() throws IOException {
@@ -689,8 +692,10 @@ abstract class AbstractPackagerTests<P extends Packager> {
}
protected ZipEntry getPackagedEntry(String name) throws IOException {
return getAllPackagedEntries().stream().filter((entry) -> name.equals(entry.getName())).findFirst()
.orElse(null);
return getAllPackagedEntries().stream()
.filter((entry) -> name.equals(entry.getName()))
.findFirst()
.orElse(null);
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2012-2022 the original author or authors.
* Copyright 2012-2023 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.
@@ -63,26 +63,26 @@ class ImplicitLayerResolverTests {
@Test
void getLayerWhenLoaderClassReturnsLoaderLayer() {
assertThat(this.layers.getLayer("org/springframework/boot/loader/Launcher.class"))
.isEqualTo(StandardLayers.SPRING_BOOT_LOADER);
.isEqualTo(StandardLayers.SPRING_BOOT_LOADER);
assertThat(this.layers.getLayer("org/springframework/boot/loader/Utils.class"))
.isEqualTo(StandardLayers.SPRING_BOOT_LOADER);
.isEqualTo(StandardLayers.SPRING_BOOT_LOADER);
}
@Test
void getLayerWhenLibraryIsSnapshotReturnsSnapshotLayer() {
assertThat(this.layers.getLayer(mockLibrary("spring-boot.2.0.0.BUILD-SNAPSHOT.jar")))
.isEqualTo(StandardLayers.SNAPSHOT_DEPENDENCIES);
.isEqualTo(StandardLayers.SNAPSHOT_DEPENDENCIES);
assertThat(this.layers.getLayer(mockLibrary("spring-boot.2.0.0-SNAPSHOT.jar")))
.isEqualTo(StandardLayers.SNAPSHOT_DEPENDENCIES);
.isEqualTo(StandardLayers.SNAPSHOT_DEPENDENCIES);
assertThat(this.layers.getLayer(mockLibrary("spring-boot.2.0.0.SNAPSHOT.jar")))
.isEqualTo(StandardLayers.SNAPSHOT_DEPENDENCIES);
.isEqualTo(StandardLayers.SNAPSHOT_DEPENDENCIES);
}
@Test
void getLayerWhenLibraryIsNotSnapshotReturnsDependenciesLayer() {
assertThat(this.layers.getLayer(mockLibrary("spring-boot.2.0.0.jar"))).isEqualTo(StandardLayers.DEPENDENCIES);
assertThat(this.layers.getLayer(mockLibrary("spring-boot.2.0.0-classified.jar")))
.isEqualTo(StandardLayers.DEPENDENCIES);
.isEqualTo(StandardLayers.DEPENDENCIES);
}
private Library mockLibrary(String name) {

View File

@@ -42,7 +42,7 @@ class LayerTests {
@Test
void createWhenNameContainsBadCharsThrowsException() {
assertThatIllegalArgumentException().isThrownBy(() -> new Layer("bad!name"))
.withMessage("Malformed layer name 'bad!name'");
.withMessage("Malformed layer name 'bad!name'");
}
@Test
@@ -62,11 +62,11 @@ class LayerTests {
@Test
void createWhenUsingReservedNameThrowsException() {
assertThatIllegalArgumentException().isThrownBy(() -> new Layer("ext"))
.withMessage("Layer name 'ext' is reserved");
.withMessage("Layer name 'ext' is reserved");
assertThatIllegalArgumentException().isThrownBy(() -> new Layer("ExT"))
.withMessage("Layer name 'ExT' is reserved");
.withMessage("Layer name 'ExT' is reserved");
assertThatIllegalArgumentException().isThrownBy(() -> new Layer("springbootloader"))
.withMessage("Layer name 'springbootloader' is reserved");
.withMessage("Layer name 'springbootloader' is reserved");
}
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2012-2020 the original author or authors.
* Copyright 2012-2023 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.
@@ -50,7 +50,7 @@ class LayoutsTests {
@Test
void unknownFile() {
assertThatIllegalStateException().isThrownBy(() -> Layouts.forFile(new File("test.txt")))
.withMessageContaining("Unable to deduce layout for 'test.txt'");
.withMessageContaining("Unable to deduce layout for 'test.txt'");
}
@Test

View File

@@ -85,8 +85,8 @@ class MainClassFinderTests {
this.testJarFile.addClass("a/b/c/E.class", ClassWithMainMethod.class);
try (JarFile jarFile = this.testJarFile.getJarFile()) {
assertThatIllegalStateException().isThrownBy(() -> MainClassFinder.findSingleMainClass(jarFile, ""))
.withMessageContaining(
"Unable to find a single main class from the following candidates [a.B, a.b.c.E]");
.withMessageContaining(
"Unable to find a single main class from the following candidates [a.B, a.b.c.E]");
}
}
@@ -142,9 +142,8 @@ class MainClassFinderTests {
this.testJarFile.addClass("a/B.class", ClassWithMainMethod.class);
this.testJarFile.addClass("a/b/c/E.class", ClassWithMainMethod.class);
assertThatIllegalStateException()
.isThrownBy(() -> MainClassFinder.findSingleMainClass(this.testJarFile.getJarSource()))
.withMessageContaining(
"Unable to find a single main class from the following candidates [a.B, a.b.c.E]");
.isThrownBy(() -> MainClassFinder.findSingleMainClass(this.testJarFile.getJarSource()))
.withMessageContaining("Unable to find a single main class from the following candidates [a.B, a.b.c.E]");
}
@Test

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2012-2022 the original author or authors.
* Copyright 2012-2023 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.
@@ -35,16 +35,16 @@ class ReachabilityMetadataPropertiesTests {
void shouldReadFromInputStream() throws IOException {
String propertiesContent = "override=true\n";
ReachabilityMetadataProperties properties = ReachabilityMetadataProperties
.fromInputStream(new ByteArrayInputStream(propertiesContent.getBytes(StandardCharsets.UTF_8)));
.fromInputStream(new ByteArrayInputStream(propertiesContent.getBytes(StandardCharsets.UTF_8)));
assertThat(properties.isOverridden()).isTrue();
}
@Test
void shouldFormatLocation() {
String location = ReachabilityMetadataProperties
.getLocation(LibraryCoordinates.of("group-id", "artifact-id", "1.0.0"));
.getLocation(LibraryCoordinates.of("group-id", "artifact-id", "1.0.0"));
assertThat(location)
.isEqualTo("META-INF/native-image/group-id/artifact-id/1.0.0/reachability-metadata.properties");
.isEqualTo("META-INF/native-image/group-id/artifact-id/1.0.0/reachability-metadata.properties");
}
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2012-2022 the original author or authors.
* Copyright 2012-2023 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.
@@ -79,7 +79,7 @@ class RepackagerTests extends AbstractPackagerTests<Repackager> {
repackager.repackage(NO_LIBRARIES);
Manifest actualManifest = getPackagedManifest();
assertThat(actualManifest.getMainAttributes().getValue("Main-Class"))
.isEqualTo("org.springframework.boot.loader.JarLauncher");
.isEqualTo("org.springframework.boot.loader.JarLauncher");
assertThat(actualManifest.getMainAttributes().getValue("Start-Class")).isEqualTo("a.b.C");
assertThat(hasPackagedLauncherClasses()).isTrue();
}
@@ -121,7 +121,7 @@ class RepackagerTests extends AbstractPackagerTests<Repackager> {
this.testJarFile.addClass("a/b/C.class", ClassWithMainMethod.class);
Repackager repackager = createRepackager(this.testJarFile.getFile(), true);
assertThatIllegalArgumentException().isThrownBy(() -> repackager.repackage(null, NO_LIBRARIES))
.withMessageContaining("Invalid destination");
.withMessageContaining("Invalid destination");
}
@Test
@@ -129,7 +129,7 @@ class RepackagerTests extends AbstractPackagerTests<Repackager> {
this.testJarFile.addClass("a/b/C.class", ClassWithMainMethod.class);
Repackager repackager = createRepackager(this.testJarFile.getFile(), true);
assertThatIllegalArgumentException().isThrownBy(() -> repackager.repackage(this.tempDir, NO_LIBRARIES))
.withMessageContaining("Invalid destination");
.withMessageContaining("Invalid destination");
}
@Test
@@ -166,7 +166,7 @@ class RepackagerTests extends AbstractPackagerTests<Repackager> {
}
try {
assertThat(Files.getPosixFilePermissions(this.destination.toPath()))
.contains(PosixFilePermission.OWNER_EXECUTE);
.contains(PosixFilePermission.OWNER_EXECUTE);
}
catch (UnsupportedOperationException ex) {
// Probably running the test on Windows
@@ -185,8 +185,10 @@ class RepackagerTests extends AbstractPackagerTests<Repackager> {
timestamp = entry.getTime();
}
else {
assertThat(entry.getTime()).withFailMessage("Expected time %d to be equal to %d for entry %s",
entry.getTime(), timestamp, entry.getName()).isEqualTo(timestamp);
assertThat(entry.getTime())
.withFailMessage("Expected time %d to be equal to %d for entry %s", entry.getTime(), timestamp,
entry.getName())
.isEqualTo(timestamp);
}
}
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2012-2022 the original author or authors.
* Copyright 2012-2023 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.
@@ -59,7 +59,7 @@ public class TestJarFile {
File file = getFilePath(filename);
file.getParentFile().mkdirs();
InputStream inputStream = getClass()
.getResourceAsStream("/" + classToCopy.getName().replace('.', '/') + ".class");
.getResourceAsStream("/" + classToCopy.getName().replace('.', '/') + ".class");
copyToFile(inputStream, file);
if (time != null) {
file.setLastModified(time);

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2012-2020 the original author or authors.
* Copyright 2012-2023 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.
@@ -33,13 +33,13 @@ class ApplicationContentFilterTests {
@Test
void createWhenPatternIsNullThrowsException() {
assertThatIllegalArgumentException().isThrownBy(() -> new ApplicationContentFilter(null))
.withMessage("Pattern must not be empty");
.withMessage("Pattern must not be empty");
}
@Test
void createWhenPatternIsEmptyThrowsException() {
assertThatIllegalArgumentException().isThrownBy(() -> new ApplicationContentFilter(""))
.withMessage("Pattern must not be empty");
.withMessage("Pattern must not be empty");
}
@Test

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2012-2020 the original author or authors.
* Copyright 2012-2023 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.
@@ -39,16 +39,17 @@ class IncludeExcludeContentSelectorTests {
@Test
void createWhenLayerIsNullThrowsException() {
assertThatIllegalArgumentException().isThrownBy(
() -> new IncludeExcludeContentSelector<>(null, Collections.emptyList(), Collections.emptyList()))
.withMessage("Layer must not be null");
assertThatIllegalArgumentException()
.isThrownBy(
() -> new IncludeExcludeContentSelector<>(null, Collections.emptyList(), Collections.emptyList()))
.withMessage("Layer must not be null");
}
@Test
void createWhenFactoryIsNullThrowsException() {
assertThatIllegalArgumentException()
.isThrownBy(() -> new IncludeExcludeContentSelector<>(LAYER, null, null, null))
.withMessage("FilterFactory must not be null");
.isThrownBy(() -> new IncludeExcludeContentSelector<>(LAYER, null, null, null))
.withMessage("FilterFactory must not be null");
}
@Test

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2012-2020 the original author or authors.
* Copyright 2012-2023 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.
@@ -38,13 +38,13 @@ class LibraryContentFilterTests {
@Test
void createWhenCoordinatesPatternIsNullThrowsException() {
assertThatIllegalArgumentException().isThrownBy(() -> new LibraryContentFilter(null))
.withMessage("CoordinatesPattern must not be empty");
.withMessage("CoordinatesPattern must not be empty");
}
@Test
void createWhenCoordinatesPatternIsEmptyThrowsException() {
assertThatIllegalArgumentException().isThrownBy(() -> new LibraryContentFilter(""))
.withMessage("CoordinatesPattern must not be empty");
.withMessage("CoordinatesPattern must not be empty");
}
@Test