diff --git a/spring-boot-devtools/src/main/java/org/springframework/boot/devtools/restart/ChangeableUrls.java b/spring-boot-devtools/src/main/java/org/springframework/boot/devtools/restart/ChangeableUrls.java index b8d013522d..a0f978a025 100644 --- a/spring-boot-devtools/src/main/java/org/springframework/boot/devtools/restart/ChangeableUrls.java +++ b/spring-boot-devtools/src/main/java/org/springframework/boot/devtools/restart/ChangeableUrls.java @@ -118,6 +118,9 @@ final class ChangeableUrls implements Iterable { } private static List getUrlsFromClassPathAttribute(URL base, Manifest manifest) { + if (manifest == null) { + return Collections.emptyList(); + } String classPath = manifest.getMainAttributes() .getValue(Attributes.Name.CLASS_PATH); if (!StringUtils.hasText(classPath)) { diff --git a/spring-boot-devtools/src/test/java/org/springframework/boot/devtools/restart/ChangeableUrlsTests.java b/spring-boot-devtools/src/test/java/org/springframework/boot/devtools/restart/ChangeableUrlsTests.java index 0e81b4fa03..eb2e846396 100644 --- a/spring-boot-devtools/src/test/java/org/springframework/boot/devtools/restart/ChangeableUrlsTests.java +++ b/spring-boot-devtools/src/test/java/org/springframework/boot/devtools/restart/ChangeableUrlsTests.java @@ -24,6 +24,7 @@ import java.net.URLClassLoader; import java.util.jar.Attributes; import java.util.jar.JarOutputStream; import java.util.jar.Manifest; +import java.util.zip.ZipOutputStream; import org.junit.Rule; import org.junit.Test; @@ -76,9 +77,11 @@ public class ChangeableUrlsTests { URL projectCore = makeUrl("project-core"); URL projectWeb = makeUrl("project-web"); File relative = this.temporaryFolder.newFolder(); - ChangeableUrls urls = ChangeableUrls.fromUrlClassLoader(new URLClassLoader( - new URL[] { makeJarFileWithUrlsInManifestClassPath(projectCore, - projectWeb, relative.getName() + "/") })); + ChangeableUrls urls = ChangeableUrls + .fromUrlClassLoader(new URLClassLoader(new URL[] { + makeJarFileWithUrlsInManifestClassPath(projectCore, projectWeb, + relative.getName() + "/"), + makeJarFileWithNoManifest() })); assertThat(urls.toList()).containsExactly(projectCore, projectWeb, relative.toURI().toURL()); } @@ -103,4 +106,10 @@ public class ChangeableUrlsTests { return classpathJar.toURI().toURL(); } + private URL makeJarFileWithNoManifest() throws Exception { + File classpathJar = this.temporaryFolder.newFile("no-manifest.jar"); + new ZipOutputStream(new FileOutputStream(classpathJar)).close(); + return classpathJar.toURI().toURL(); + } + }