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) {
119119 }
120120
121121 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+ }
123125 String classPathAttribute = manifest .getMainAttributes ()
124126 .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 );
135139 }
136140 }
137141 return urls ;
Original file line number Diff line number Diff line change 2424import java .util .jar .Attributes ;
2525import java .util .jar .JarOutputStream ;
2626import java .util .jar .Manifest ;
27+ import java .util .zip .ZipOutputStream ;
2728
2829import org .junit .Rule ;
2930import org .junit .Test ;
@@ -80,7 +81,7 @@ public void urlsFromJarClassPathAreConsidered() throws Exception {
8081 File relative = this .temporaryFolder .newFolder ();
8182 ChangeableUrls urls = ChangeableUrls .fromUrlClassLoader (new URLClassLoader (
8283 new URL [] { makeJarFileWithUrlsInManifestClassPath (projectCore ,
83- projectWeb , relative .getName () + "/" ) }));
84+ projectWeb , relative .getName () + "/" ), makeJarFileWithNoManifest () }));
8485 assertThat (urls .toList (),
8586 contains (projectCore , projectWeb , relative .toURI ().toURL ()));
8687 }
@@ -105,4 +106,10 @@ private URL makeJarFileWithUrlsInManifestClassPath(Object... urls) throws Except
105106 return classpathJar .toURI ().toURL ();
106107 }
107108
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+
108115}
You can’t perform that action at this time.
0 commit comments