diff --git a/spring-boot-project/spring-boot-tools/spring-boot-loader/src/main/java/org/springframework/boot/loader/Launcher.java b/spring-boot-project/spring-boot-tools/spring-boot-loader/src/main/java/org/springframework/boot/loader/Launcher.java index d33121ba91..314da4090b 100644 --- a/spring-boot-project/spring-boot-tools/spring-boot-loader/src/main/java/org/springframework/boot/loader/Launcher.java +++ b/spring-boot-project/spring-boot-tools/spring-boot-loader/src/main/java/org/springframework/boot/loader/Launcher.java @@ -80,9 +80,7 @@ public abstract class Launcher { protected ClassLoader createClassLoader(Iterator archives) throws Exception { List urls = new ArrayList<>(50); while (archives.hasNext()) { - Archive archive = archives.next(); - urls.add(archive.getUrl()); - archive.close(); + urls.add(archives.next().getUrl()); } return createClassLoader(urls.toArray(new URL[0])); } diff --git a/spring-boot-project/spring-boot-tools/spring-boot-loader/src/test/java/org/springframework/boot/loader/PropertiesLauncherTests.java b/spring-boot-project/spring-boot-tools/spring-boot-loader/src/test/java/org/springframework/boot/loader/PropertiesLauncherTests.java index 5901fa6f1c..53fb071df7 100644 --- a/spring-boot-project/spring-boot-tools/spring-boot-loader/src/test/java/org/springframework/boot/loader/PropertiesLauncherTests.java +++ b/spring-boot-project/spring-boot-tools/spring-boot-loader/src/test/java/org/springframework/boot/loader/PropertiesLauncherTests.java @@ -233,12 +233,13 @@ class PropertiesLauncherTests { @Test void testUserSpecifiedNestedJarPath() throws Exception { - System.setProperty("loader.path", "nested-jars/app.jar!/foo.jar"); + System.setProperty("loader.path", "nested-jars/nested-jar-app.jar!/BOOT-INF/classes/"); System.setProperty("loader.main", "demo.Application"); this.launcher = new PropertiesLauncher(); - List archives = new ArrayList<>(); - this.launcher.getClassPathArchivesIterator().forEachRemaining(archives::add); - assertThat(archives).hasSize(1).areExactly(1, endingWith("foo.jar!/")); + assertThat(ReflectionTestUtils.getField(this.launcher, "paths").toString()) + .isEqualTo("[nested-jars/nested-jar-app.jar!/BOOT-INF/classes/]"); + this.launcher.launch(new String[0]); + waitFor("Hello World"); } @Test diff --git a/spring-boot-project/spring-boot-tools/spring-boot-loader/src/test/resources/nested-jars/nested-jar-app.jar b/spring-boot-project/spring-boot-tools/spring-boot-loader/src/test/resources/nested-jars/nested-jar-app.jar new file mode 100644 index 0000000000..4c2254f635 Binary files /dev/null and b/spring-boot-project/spring-boot-tools/spring-boot-loader/src/test/resources/nested-jars/nested-jar-app.jar differ