diff --git a/spring-boot-project/spring-boot-tools/spring-boot-loader/src/main/java/org/springframework/boot/loader/PropertiesLauncher.java b/spring-boot-project/spring-boot-tools/spring-boot-loader/src/main/java/org/springframework/boot/loader/PropertiesLauncher.java index 200b418634..b1eb6b2947 100755 --- a/spring-boot-project/spring-boot-tools/spring-boot-loader/src/main/java/org/springframework/boot/loader/PropertiesLauncher.java +++ b/spring-boot-project/spring-boot-tools/spring-boot-loader/src/main/java/org/springframework/boot/loader/PropertiesLauncher.java @@ -483,6 +483,10 @@ public class PropertiesLauncher extends Launcher { } private Archive getArchive(File file) throws IOException { + // Nested path never exists as plain jar file, which should be ignored here. + if (file.getPath().contains("!")) { + return null; + } String name = file.getName().toLowerCase(); if (name.endsWith(".jar") || name.endsWith(".zip")) { return new JarFileArchive(file); 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 ce816b9258..9de725c7b4 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 @@ -213,6 +213,15 @@ public class PropertiesLauncherTests { assertThat(archives).areExactly(1, endingWith("app.jar!/")); } + @Test + public void testUserSpecifiedNestedJarPath() throws Exception { + System.setProperty("loader.path", "nested-jars/app.jar!/foo.jar"); + System.setProperty("loader.main", "demo.Application"); + PropertiesLauncher launcher = new PropertiesLauncher(); + List archives = launcher.getClassPathArchives(); + assertThat(archives).hasSize(1).areExactly(1, endingWith("foo.jar!/")); + } + @Test public void testUserSpecifiedDirectoryContainingJarFileWithNestedArchives() throws Exception {