File tree Expand file tree Collapse file tree 2 files changed +23
-12
lines changed
main/java/org/springframework/boot/devtools/restart
test/java/org/springframework/boot/devtools/restart Expand file tree Collapse file tree 2 files changed +23
-12
lines changed Original file line number Diff line number Diff line change @@ -119,19 +119,23 @@ private static JarFile getJarFileIfPossible(URL url) {
119
119
}
120
120
121
121
private static List <URL > getUrlsFromClassPathAttribute (URL base , Manifest manifest ) {
122
- List <URL > urls = new ArrayList <URL >();
122
+ if (manifest == null ) {
123
+ return Collections .<URL >emptyList ();
124
+ }
123
125
String classPathAttribute = manifest .getMainAttributes ()
124
126
.getValue (Attributes .Name .CLASS_PATH );
125
- if (StringUtils .hasText (classPathAttribute )) {
126
- for (String entry : StringUtils .delimitedListToStringArray (classPathAttribute ,
127
- " " )) {
128
- try {
129
- urls .add (new URL (base , entry ));
130
- }
131
- catch (MalformedURLException ex ) {
132
- throw new IllegalStateException (
133
- "Class-Path attribute contains malformed URL" , ex );
134
- }
127
+ if (!StringUtils .hasText (classPathAttribute )) {
128
+ return Collections .<URL >emptyList ();
129
+ }
130
+ List <URL > urls = new ArrayList <URL >();
131
+ for (String entry : StringUtils .delimitedListToStringArray (classPathAttribute ,
132
+ " " )) {
133
+ try {
134
+ urls .add (new URL (base , entry ));
135
+ }
136
+ catch (MalformedURLException ex ) {
137
+ throw new IllegalStateException (
138
+ "Class-Path attribute contains malformed URL" , ex );
135
139
}
136
140
}
137
141
return urls ;
Original file line number Diff line number Diff line change 24
24
import java .util .jar .Attributes ;
25
25
import java .util .jar .JarOutputStream ;
26
26
import java .util .jar .Manifest ;
27
+ import java .util .zip .ZipOutputStream ;
27
28
28
29
import org .junit .Rule ;
29
30
import org .junit .Test ;
@@ -80,7 +81,7 @@ public void urlsFromJarClassPathAreConsidered() throws Exception {
80
81
File relative = this .temporaryFolder .newFolder ();
81
82
ChangeableUrls urls = ChangeableUrls .fromUrlClassLoader (new URLClassLoader (
82
83
new URL [] { makeJarFileWithUrlsInManifestClassPath (projectCore ,
83
- projectWeb , relative .getName () + "/" ) }));
84
+ projectWeb , relative .getName () + "/" ), makeJarFileWithNoManifest () }));
84
85
assertThat (urls .toList (),
85
86
contains (projectCore , projectWeb , relative .toURI ().toURL ()));
86
87
}
@@ -105,4 +106,10 @@ private URL makeJarFileWithUrlsInManifestClassPath(Object... urls) throws Except
105
106
return classpathJar .toURI ().toURL ();
106
107
}
107
108
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
+
108
115
}
You can’t perform that action at this time.
0 commit comments