Skip to content

Commit 43256ee

Browse files
committed
Merge branch '1.3.x'
2 parents 06c1dd8 + b554894 commit 43256ee

File tree

2 files changed

+15
-3
lines changed

2 files changed

+15
-3
lines changed

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

+3
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,9 @@ private static JarFile getJarFileIfPossible(URL url) {
118118
}
119119

120120
private static List<URL> getUrlsFromClassPathAttribute(URL base, Manifest manifest) {
121+
if (manifest == null) {
122+
return Collections.<URL>emptyList();
123+
}
121124
String classPath = manifest.getMainAttributes()
122125
.getValue(Attributes.Name.CLASS_PATH);
123126
if (!StringUtils.hasText(classPath)) {

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

+12-3
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
import java.util.jar.Attributes;
2525
import java.util.jar.JarOutputStream;
2626
import java.util.jar.Manifest;
27+
import java.util.zip.ZipOutputStream;
2728

2829
import org.junit.Rule;
2930
import org.junit.Test;
@@ -76,9 +77,11 @@ public void urlsFromJarClassPathAreConsidered() throws Exception {
7677
URL projectCore = makeUrl("project-core");
7778
URL projectWeb = makeUrl("project-web");
7879
File relative = this.temporaryFolder.newFolder();
79-
ChangeableUrls urls = ChangeableUrls.fromUrlClassLoader(new URLClassLoader(
80-
new URL[] { makeJarFileWithUrlsInManifestClassPath(projectCore,
81-
projectWeb, relative.getName() + "/") }));
80+
ChangeableUrls urls = ChangeableUrls
81+
.fromUrlClassLoader(new URLClassLoader(new URL[] {
82+
makeJarFileWithUrlsInManifestClassPath(projectCore, projectWeb,
83+
relative.getName() + "/"),
84+
makeJarFileWithNoManifest() }));
8285
assertThat(urls.toList()).containsExactly(projectCore, projectWeb,
8386
relative.toURI().toURL());
8487
}
@@ -103,4 +106,10 @@ private URL makeJarFileWithUrlsInManifestClassPath(Object... urls) throws Except
103106
return classpathJar.toURI().toURL();
104107
}
105108

109+
private URL makeJarFileWithNoManifest() throws Exception {
110+
File classpathJar = this.temporaryFolder.newFile("no-manifest.jar");
111+
new ZipOutputStream(new FileOutputStream(classpathJar)).close();
112+
return classpathJar.toURI().toURL();
113+
}
114+
106115
}

0 commit comments

Comments
 (0)