Update Devtools to ignore manifest Class-Path entries that do not exist

Closes gh-8623
This commit is contained in:
Andy Wilkinson
2017-04-04 12:15:51 +01:00
parent 456327260b
commit 47de05b52c
2 changed files with 28 additions and 13 deletions

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2012-2016 the original author or authors.
* Copyright 2012-2017 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -96,7 +96,7 @@ final class ChangeableUrls implements Iterable<URL> {
return Collections.<URL>emptyList();
}
try {
return getUrlsFromClassPathAttribute(url, jarFile.getManifest());
return getUrlsFromManifestClassPathAttribute(jarFile);
}
catch (IOException ex) {
throw new IllegalStateException(
@@ -118,7 +118,9 @@ final class ChangeableUrls implements Iterable<URL> {
return null;
}
private static List<URL> getUrlsFromClassPathAttribute(URL base, Manifest manifest) {
private static List<URL> getUrlsFromManifestClassPathAttribute(JarFile jarFile)
throws IOException {
Manifest manifest = jarFile.getManifest();
if (manifest == null) {
return Collections.<URL>emptyList();
}
@@ -129,9 +131,18 @@ final class ChangeableUrls implements Iterable<URL> {
}
String[] entries = StringUtils.delimitedListToStringArray(classPath, " ");
List<URL> urls = new ArrayList<URL>(entries.length);
File parent = new File(jarFile.getName()).getParentFile();
for (String entry : entries) {
try {
urls.add(new URL(base, entry));
File referenced = new File(parent, entry);
if (referenced.exists()) {
urls.add(referenced.toURI().toURL());
}
else {
System.err.println("Ignoring Class-Path entry " + entry + " found in"
+ jarFile.getName() + " as " + referenced
+ " does not exist");
}
}
catch (MalformedURLException ex) {
throw new IllegalStateException(