Fix nested archive paths logging in PropertiesLauncher

See gh-50968

Signed-off-by: Filip Hrisafov <filip.hrisafov@gmail.com>
This commit is contained in:
Filip Hrisafov
2026-07-21 14:58:48 +02:00
committed by Stéphane Nicoll
parent 629a01adf1
commit 2578e81796
2 changed files with 13 additions and 16 deletions
@@ -136,8 +136,6 @@ public class PropertiesLauncher extends Launcher {
private final File homeDirectory;
private final List<String> paths;
private final Properties properties = new Properties();
public PropertiesLauncher() throws Exception {
@@ -148,7 +146,6 @@ public class PropertiesLauncher extends Launcher {
this.archive = archive;
this.homeDirectory = getHomeDirectory();
initializeProperties();
this.paths = getPaths();
this.classPathIndex = getClassPathIndex(this.archive);
}
@@ -295,7 +292,7 @@ public class PropertiesLauncher extends Launcher {
private List<String> getPaths() throws Exception {
String path = getProperty(PATH);
List<String> paths = (path != null) ? parsePathsProperty(path) : Collections.emptyList();
debug.log("Nested archive paths: %s", this.paths);
debug.log("Nested archive paths: %s", paths);
return paths;
}
@@ -127,7 +127,7 @@ class PropertiesLauncherTests extends AbstractLauncherTests {
System.setProperty("loader.config.name", "foo");
this.launcher = new PropertiesLauncher();
assertThat(this.launcher.getMainClass()).isEqualTo("my.Application");
assertThat(ReflectionTestUtils.getField(this.launcher, "paths")).hasToString("[etc/]");
assertThat(ReflectionTestUtils.<Object>invokeMethod(this.launcher, "getPaths")).hasToString("[etc/]");
}
@Test
@@ -141,14 +141,14 @@ class PropertiesLauncherTests extends AbstractLauncherTests {
void testUserSpecifiedDotPath() throws Exception {
System.setProperty("loader.path", ".");
this.launcher = new PropertiesLauncher();
assertThat(ReflectionTestUtils.getField(this.launcher, "paths")).hasToString("[.]");
assertThat(ReflectionTestUtils.<Object>invokeMethod(this.launcher, "getPaths")).hasToString("[.]");
}
@Test
void testUserSpecifiedSlashPath() throws Exception {
System.setProperty("loader.path", "jars/");
this.launcher = new PropertiesLauncher();
assertThat(ReflectionTestUtils.getField(this.launcher, "paths")).hasToString("[jars/]");
assertThat(ReflectionTestUtils.<Object>invokeMethod(this.launcher, "getPaths")).hasToString("[jars/]");
Set<URL> urls = this.launcher.getClassPathUrls();
assertThat(urls).areExactly(1, endingWith("app.jar"));
}
@@ -158,7 +158,7 @@ class PropertiesLauncherTests extends AbstractLauncherTests {
System.setProperty("loader.path", "jars/*");
System.setProperty("loader.main", "demo.Application");
this.launcher = new PropertiesLauncher();
assertThat(ReflectionTestUtils.getField(this.launcher, "paths")).hasToString("[jars/]");
assertThat(ReflectionTestUtils.<Object>invokeMethod(this.launcher, "getPaths")).hasToString("[jars/]");
this.launcher.launch(new String[0]);
waitFor("Hello World");
}
@@ -168,7 +168,7 @@ class PropertiesLauncherTests extends AbstractLauncherTests {
System.setProperty("loader.path", "jars/app.jar");
System.setProperty("loader.main", "demo.Application");
this.launcher = new PropertiesLauncher();
assertThat(ReflectionTestUtils.getField(this.launcher, "paths")).hasToString("[jars/app.jar]");
assertThat(ReflectionTestUtils.<Object>invokeMethod(this.launcher, "getPaths")).hasToString("[jars/app.jar]");
this.launcher.launch(new String[0]);
waitFor("Hello World");
}
@@ -177,7 +177,7 @@ class PropertiesLauncherTests extends AbstractLauncherTests {
void testUserSpecifiedRootOfJarPath() throws Exception {
System.setProperty("loader.path", "jar:file:./src/test/resources/nested-jars/app.jar!/");
this.launcher = new PropertiesLauncher();
assertThat(ReflectionTestUtils.getField(this.launcher, "paths"))
assertThat(ReflectionTestUtils.<Object>invokeMethod(this.launcher, "getPaths"))
.hasToString("[jar:file:./src/test/resources/nested-jars/app.jar!/]");
Set<URL> urls = this.launcher.getClassPathUrls();
assertThat(urls).areExactly(1, endingWith("foo.jar!/"));
@@ -216,7 +216,7 @@ class PropertiesLauncherTests extends AbstractLauncherTests {
System.setProperty("loader.path", "nested-jars/nested-jar-app.jar!/BOOT-INF/classes/");
System.setProperty("loader.main", "demo.Application");
this.launcher = new PropertiesLauncher();
assertThat(ReflectionTestUtils.getField(this.launcher, "paths"))
assertThat(ReflectionTestUtils.<Object>invokeMethod(this.launcher, "getPaths"))
.hasToString("[nested-jars/nested-jar-app.jar!/BOOT-INF/classes/]");
this.launcher.launch(new String[0]);
waitFor("Hello World");
@@ -236,7 +236,7 @@ class PropertiesLauncherTests extends AbstractLauncherTests {
System.setProperty("loader.path", "./jars/app.jar");
System.setProperty("loader.main", "demo.Application");
this.launcher = new PropertiesLauncher();
assertThat(ReflectionTestUtils.getField(this.launcher, "paths")).hasToString("[jars/app.jar]");
assertThat(ReflectionTestUtils.<Object>invokeMethod(this.launcher, "getPaths")).hasToString("[jars/app.jar]");
this.launcher.launch(new String[0]);
waitFor("Hello World");
}
@@ -246,7 +246,7 @@ class PropertiesLauncherTests extends AbstractLauncherTests {
System.setProperty("loader.path", "jars/app.jar");
System.setProperty("loader.classLoader", URLClassLoader.class.getName());
this.launcher = new PropertiesLauncher();
assertThat(ReflectionTestUtils.getField(this.launcher, "paths")).hasToString("[jars/app.jar]");
assertThat(ReflectionTestUtils.<Object>invokeMethod(this.launcher, "getPaths")).hasToString("[jars/app.jar]");
this.launcher.launch(new String[0]);
waitFor("Hello World");
}
@@ -256,7 +256,7 @@ class PropertiesLauncherTests extends AbstractLauncherTests {
System.setProperty("loader.path", "more-jars/app.jar,jars/app.jar");
System.setProperty("loader.classLoader", URLClassLoader.class.getName());
this.launcher = new PropertiesLauncher();
assertThat(ReflectionTestUtils.getField(this.launcher, "paths"))
assertThat(ReflectionTestUtils.<Object>invokeMethod(this.launcher, "getPaths"))
.hasToString("[more-jars/app.jar, jars/app.jar]");
this.launcher.launch(new String[0]);
waitFor("Hello Other World");
@@ -325,8 +325,8 @@ class PropertiesLauncherTests extends AbstractLauncherTests {
manifest.write(manifestStream);
}
this.launcher = new PropertiesLauncher();
assertThat((List<String>) ReflectionTestUtils.getField(this.launcher, "paths")).containsExactly("/foo.jar",
"/bar/");
assertThat((List<String>) ReflectionTestUtils.invokeMethod(this.launcher, "getPaths"))
.containsExactly("/foo.jar", "/bar/");
}
@Test