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 9356c4cb4e9..927753770c7 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 @@ -94,7 +94,7 @@ final class ChangeableUrls implements Iterable { JarFile jarFile = getJarFileIfPossible(url); if (jarFile != null) { try { - return getUrlsFromClassPathAttribute(jarFile.getManifest()); + return getUrlsFromClassPathAttribute(url, jarFile.getManifest()); } catch (IOException ex) { throw new IllegalStateException( @@ -118,7 +118,7 @@ final class ChangeableUrls implements Iterable { return null; } - private static List getUrlsFromClassPathAttribute(Manifest manifest) { + private static List getUrlsFromClassPathAttribute(URL base, Manifest manifest) { List urls = new ArrayList(); String classPathAttribute = manifest.getMainAttributes() .getValue(Attributes.Name.CLASS_PATH); @@ -126,7 +126,7 @@ final class ChangeableUrls implements Iterable { for (String entry : StringUtils.delimitedListToStringArray(classPathAttribute, " ")) { try { - urls.add(new URL(entry)); + urls.add(new URL(base, entry)); } catch (MalformedURLException ex) { throw new IllegalStateException( 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 723e5588665..117e2d67cc0 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 @@ -77,10 +77,12 @@ public class ChangeableUrlsTests { public void urlsFromJarClassPathAreConsidered() throws Exception { 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) })); - assertThat(urls.toList(), contains(projectCore, projectWeb)); + projectWeb, relative.getName() + "/") })); + assertThat(urls.toList(), + contains(projectCore, projectWeb, relative.toURI().toURL())); } private URL makeUrl(String name) throws IOException { @@ -92,7 +94,7 @@ public class ChangeableUrlsTests { return file.toURI().toURL(); } - private URL makeJarFileWithUrlsInManifestClassPath(URL... urls) throws Exception { + private URL makeJarFileWithUrlsInManifestClassPath(Object... urls) throws Exception { File classpathJar = this.temporaryFolder.newFile("classpath.jar"); Manifest manifest = new Manifest(); manifest.getMainAttributes().putValue(Attributes.Name.MANIFEST_VERSION.toString(),