Commit 38552065 authored by Andy Wilkinson's avatar Andy Wilkinson

Merge branch '2.1.x'

Closes gh-17114
parents a084cc3f 7103eab2
...@@ -117,29 +117,24 @@ final class ChangeableUrls implements Iterable<URL> { ...@@ -117,29 +117,24 @@ final class ChangeableUrls implements Iterable<URL> {
} }
private static List<URL> getUrlsFromClassPathOfJarManifestIfPossible(URL url) { private static List<URL> getUrlsFromClassPathOfJarManifestIfPossible(URL url) {
JarFile jarFile = getJarFileIfPossible(url); try {
if (jarFile == null) { File file = new File(url.toURI());
return Collections.emptyList(); if (file.isFile()) {
} try (JarFile jarFile = new JarFile(file)) {
try { try {
return getUrlsFromManifestClassPathAttribute(url, jarFile); return getUrlsFromManifestClassPathAttribute(url, jarFile);
} }
catch (IOException ex) { catch (IOException ex) {
throw new IllegalStateException("Failed to read Class-Path attribute from manifest of jar " + url, ex); throw new IllegalStateException(
"Failed to read Class-Path attribute from manifest of jar " + url, ex);
} }
} }
private static JarFile getJarFileIfPossible(URL url) {
try {
File file = new File(url.toURI());
if (file.isFile()) {
return new JarFile(file);
} }
} }
catch (Exception ex) { catch (Exception ex) {
// Assume it's not a jar and continue // Assume it's not a jar and continue
} }
return null; return Collections.emptyList();
} }
private static List<URL> getUrlsFromManifestClassPathAttribute(URL jarUrl, JarFile jarFile) throws IOException { private static List<URL> getUrlsFromManifestClassPathAttribute(URL jarUrl, JarFile jarFile) throws IOException {
......
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