Skip to content

Commit b6a0d67

Browse files
committed
Merge branch '1.5.x'
2 parents 75dbe5c + c27d678 commit b6a0d67

File tree

2 files changed

+11
-14
lines changed

2 files changed

+11
-14
lines changed

spring-boot-devtools/src/main/java/org/springframework/boot/devtools/restart/ChangeableUrls.java

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ private static List<URL> getUrlsFromClassPathOfJarManifestIfPossible(URL url) {
104104
return Collections.<URL>emptyList();
105105
}
106106
try {
107-
return getUrlsFromManifestClassPathAttribute(jarFile);
107+
return getUrlsFromManifestClassPathAttribute(url, jarFile);
108108
}
109109
catch (IOException ex) {
110110
throw new IllegalStateException(
@@ -126,8 +126,8 @@ private static JarFile getJarFileIfPossible(URL url) {
126126
return null;
127127
}
128128

129-
private static List<URL> getUrlsFromManifestClassPathAttribute(JarFile jarFile)
130-
throws IOException {
129+
private static List<URL> getUrlsFromManifestClassPathAttribute(URL jarUrl,
130+
JarFile jarFile) throws IOException {
131131
Manifest manifest = jarFile.getManifest();
132132
if (manifest == null) {
133133
return Collections.<URL>emptyList();
@@ -139,16 +139,12 @@ private static List<URL> getUrlsFromManifestClassPathAttribute(JarFile jarFile)
139139
}
140140
String[] entries = StringUtils.delimitedListToStringArray(classPath, " ");
141141
List<URL> urls = new ArrayList<>(entries.length);
142-
File parent = new File(jarFile.getName()).getParentFile();
143-
List<File> nonExistentEntries = new ArrayList<>();
142+
List<URL> nonExistentEntries = new ArrayList<>();
144143
for (String entry : entries) {
145144
try {
146-
File referenced = new File(entry);
147-
if (!referenced.isAbsolute()) {
148-
referenced = new File(parent, entry);
149-
}
150-
if (referenced.exists()) {
151-
urls.add(referenced.toURI().toURL());
145+
URL referenced = new URL(jarUrl, entry);
146+
if (new File(referenced.getFile()).exists()) {
147+
urls.add(referenced);
152148
}
153149
else {
154150
nonExistentEntries.add(referenced);

spring-boot-devtools/src/test/java/org/springframework/boot/devtools/restart/ChangeableUrlsTests.java

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -75,11 +75,12 @@ public void skipsUrls() throws Exception {
7575
@Test
7676
public void urlsFromJarClassPathAreConsidered() throws Exception {
7777
File relative = this.temporaryFolder.newFolder();
78-
File absolute = this.temporaryFolder.newFolder();
78+
File absoluteFile = this.temporaryFolder.newFolder();
79+
URL absoluteUrl = this.temporaryFolder.newFolder().toURI().toURL();
7980
File jarWithClassPath = makeJarFileWithUrlsInManifestClassPath(
8081
"project-core/target/classes/", "project-web/target/classes/",
8182
"does-not-exist/target/classes", relative.getName() + "/",
82-
absolute.getAbsolutePath() + "/");
83+
absoluteFile.getAbsolutePath() + "/", absoluteUrl);
8384
new File(jarWithClassPath.getParentFile(), "project-core/target/classes")
8485
.mkdirs();
8586
new File(jarWithClassPath.getParentFile(), "project-web/target/classes").mkdirs();
@@ -89,7 +90,7 @@ public void urlsFromJarClassPathAreConsidered() throws Exception {
8990
assertThat(urls.toList()).containsExactly(
9091
new URL(jarWithClassPath.toURI().toURL(), "project-core/target/classes/"),
9192
new URL(jarWithClassPath.toURI().toURL(), "project-web/target/classes/"),
92-
relative.toURI().toURL(), absolute.toURI().toURL());
93+
relative.toURI().toURL(), absoluteFile.toURI().toURL(), absoluteUrl);
9394
}
9495

9596
private URL makeUrl(String name) throws IOException {

0 commit comments

Comments
 (0)