Commit 43256ee7 authored by Andy Wilkinson's avatar Andy Wilkinson

Merge branch '1.3.x'

parents 06c1dd87 b554894b
...@@ -118,6 +118,9 @@ final class ChangeableUrls implements Iterable<URL> { ...@@ -118,6 +118,9 @@ final class ChangeableUrls implements Iterable<URL> {
} }
private static List<URL> getUrlsFromClassPathAttribute(URL base, Manifest manifest) { private static List<URL> getUrlsFromClassPathAttribute(URL base, Manifest manifest) {
if (manifest == null) {
return Collections.<URL>emptyList();
}
String classPath = manifest.getMainAttributes() String classPath = manifest.getMainAttributes()
.getValue(Attributes.Name.CLASS_PATH); .getValue(Attributes.Name.CLASS_PATH);
if (!StringUtils.hasText(classPath)) { if (!StringUtils.hasText(classPath)) {
......
...@@ -24,6 +24,7 @@ import java.net.URLClassLoader; ...@@ -24,6 +24,7 @@ import java.net.URLClassLoader;
import java.util.jar.Attributes; import java.util.jar.Attributes;
import java.util.jar.JarOutputStream; import java.util.jar.JarOutputStream;
import java.util.jar.Manifest; import java.util.jar.Manifest;
import java.util.zip.ZipOutputStream;
import org.junit.Rule; import org.junit.Rule;
import org.junit.Test; import org.junit.Test;
...@@ -76,9 +77,11 @@ public class ChangeableUrlsTests { ...@@ -76,9 +77,11 @@ public class ChangeableUrlsTests {
URL projectCore = makeUrl("project-core"); URL projectCore = makeUrl("project-core");
URL projectWeb = makeUrl("project-web"); URL projectWeb = makeUrl("project-web");
File relative = this.temporaryFolder.newFolder(); File relative = this.temporaryFolder.newFolder();
ChangeableUrls urls = ChangeableUrls.fromUrlClassLoader(new URLClassLoader( ChangeableUrls urls = ChangeableUrls
new URL[] { makeJarFileWithUrlsInManifestClassPath(projectCore, .fromUrlClassLoader(new URLClassLoader(new URL[] {
projectWeb, relative.getName() + "/") })); makeJarFileWithUrlsInManifestClassPath(projectCore, projectWeb,
relative.getName() + "/"),
makeJarFileWithNoManifest() }));
assertThat(urls.toList()).containsExactly(projectCore, projectWeb, assertThat(urls.toList()).containsExactly(projectCore, projectWeb,
relative.toURI().toURL()); relative.toURI().toURL());
} }
...@@ -103,4 +106,10 @@ public class ChangeableUrlsTests { ...@@ -103,4 +106,10 @@ public class ChangeableUrlsTests {
return classpathJar.toURI().toURL(); return classpathJar.toURI().toURL();
} }
private URL makeJarFileWithNoManifest() throws Exception {
File classpathJar = this.temporaryFolder.newFile("no-manifest.jar");
new ZipOutputStream(new FileOutputStream(classpathJar)).close();
return classpathJar.toURI().toURL();
}
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment