Tolerate jar files with no manifest in ChangeableUrls

Closes gh-5704
This commit is contained in:
Andy Wilkinson
2016-04-15 17:11:41 +01:00
parent a2f482b7f3
commit 1fbd43bdf0
2 changed files with 23 additions and 12 deletions

View File

@@ -119,19 +119,23 @@ final class ChangeableUrls implements Iterable<URL> {
}
private static List<URL> getUrlsFromClassPathAttribute(URL base, Manifest manifest) {
List<URL> urls = new ArrayList<URL>();
if (manifest == null) {
return Collections.<URL>emptyList();
}
String classPathAttribute = manifest.getMainAttributes()
.getValue(Attributes.Name.CLASS_PATH);
if (StringUtils.hasText(classPathAttribute)) {
for (String entry : StringUtils.delimitedListToStringArray(classPathAttribute,
" ")) {
try {
urls.add(new URL(base, entry));
}
catch (MalformedURLException ex) {
throw new IllegalStateException(
"Class-Path attribute contains malformed URL", ex);
}
if (!StringUtils.hasText(classPathAttribute)) {
return Collections.<URL>emptyList();
}
List<URL> urls = new ArrayList<URL>();
for (String entry : StringUtils.delimitedListToStringArray(classPathAttribute,
" ")) {
try {
urls.add(new URL(base, entry));
}
catch (MalformedURLException ex) {
throw new IllegalStateException(
"Class-Path attribute contains malformed URL", ex);
}
}
return urls;