Merge branch '1.3.x'

This commit is contained in:
Andy Wilkinson 2016-04-15 17:33:25 +01:00
commit 43256ee7c9
2 changed files with 15 additions and 3 deletions

View File

@ -118,6 +118,9 @@ final class ChangeableUrls implements Iterable<URL> {
}
private static List<URL> getUrlsFromClassPathAttribute(URL base, Manifest manifest) {
if (manifest == null) {
return Collections.<URL>emptyList();
}
String classPath = manifest.getMainAttributes()
.getValue(Attributes.Name.CLASS_PATH);
if (!StringUtils.hasText(classPath)) {

View File

@ -24,6 +24,7 @@ import java.net.URLClassLoader;
import java.util.jar.Attributes;
import java.util.jar.JarOutputStream;
import java.util.jar.Manifest;
import java.util.zip.ZipOutputStream;
import org.junit.Rule;
import org.junit.Test;
@ -76,9 +77,11 @@ public class ChangeableUrlsTests {
URL projectCore = makeUrl("project-core");
URL projectWeb = makeUrl("project-web");
File relative = this.temporaryFolder.newFolder();
ChangeableUrls urls = ChangeableUrls.fromUrlClassLoader(new URLClassLoader(
new URL[] { makeJarFileWithUrlsInManifestClassPath(projectCore,
projectWeb, relative.getName() + "/") }));
ChangeableUrls urls = ChangeableUrls
.fromUrlClassLoader(new URLClassLoader(new URL[] {
makeJarFileWithUrlsInManifestClassPath(projectCore, projectWeb,
relative.getName() + "/"),
makeJarFileWithNoManifest() }));
assertThat(urls.toList()).containsExactly(projectCore, projectWeb,
relative.toURI().toURL());
}
@ -103,4 +106,10 @@ public class ChangeableUrlsTests {
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();
}
}