From 7eb9193862eecc8a0d3f2a64aa11af095358c822 Mon Sep 17 00:00:00 2001 From: Andy Wilkinson Date: Mon, 25 Sep 2017 16:46:47 +0100 Subject: [PATCH] Tolerate absolute URLs in manifest's Class-Path attribute Closes gh-10268 --- .../boot/devtools/restart/ChangeableUrls.java | 5 ++++- .../boot/devtools/restart/ChangeableUrlsTests.java | 6 ++++-- 2 files changed, 8 insertions(+), 3 deletions(-) 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 ed2e090a9aa..d0b122d8cef 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 @@ -143,7 +143,10 @@ final class ChangeableUrls implements Iterable { List nonExistentEntries = new ArrayList(); for (String entry : entries) { try { - File referenced = new File(parent, entry); + File referenced = new File(entry); + if (!referenced.isAbsolute()) { + referenced = new File(parent, entry); + } if (referenced.exists()) { urls.add(referenced.toURI().toURL()); } 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 9e5de5abe54..c49ddd23f62 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 @@ -75,9 +75,11 @@ public class ChangeableUrlsTests { @Test public void urlsFromJarClassPathAreConsidered() throws Exception { File relative = this.temporaryFolder.newFolder(); + File absolute = this.temporaryFolder.newFolder(); File jarWithClassPath = makeJarFileWithUrlsInManifestClassPath( "project-core/target/classes/", "project-web/target/classes/", - "does-not-exist/target/classes", relative.getName() + "/"); + "does-not-exist/target/classes", relative.getName() + "/", + absolute.getAbsolutePath() + "/"); new File(jarWithClassPath.getParentFile(), "project-core/target/classes") .mkdirs(); new File(jarWithClassPath.getParentFile(), "project-web/target/classes").mkdirs(); @@ -87,7 +89,7 @@ public class ChangeableUrlsTests { assertThat(urls.toList()).containsExactly( new URL(jarWithClassPath.toURI().toURL(), "project-core/target/classes/"), new URL(jarWithClassPath.toURI().toURL(), "project-web/target/classes/"), - relative.toURI().toURL()); + relative.toURI().toURL(), absolute.toURI().toURL()); } private URL makeUrl(String name) throws IOException {