|
|
|
@ -18,14 +18,13 @@ package org.springframework.boot.web.servlet.server;
|
|
|
|
|
|
|
|
|
|
import java.io.File;
|
|
|
|
|
import java.io.IOException;
|
|
|
|
|
import java.io.UnsupportedEncodingException;
|
|
|
|
|
import java.lang.management.ManagementFactory;
|
|
|
|
|
import java.net.JarURLConnection;
|
|
|
|
|
import java.net.MalformedURLException;
|
|
|
|
|
import java.net.URISyntaxException;
|
|
|
|
|
import java.net.URL;
|
|
|
|
|
import java.net.URLClassLoader;
|
|
|
|
|
import java.net.URLConnection;
|
|
|
|
|
import java.net.URLDecoder;
|
|
|
|
|
import java.util.ArrayList;
|
|
|
|
|
import java.util.List;
|
|
|
|
|
import java.util.jar.JarFile;
|
|
|
|
@ -71,10 +70,20 @@ class StaticResourceJars {
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private File toFile(URL url) {
|
|
|
|
|
try {
|
|
|
|
|
return new File(url.toURI());
|
|
|
|
|
}
|
|
|
|
|
catch (URISyntaxException ex) {
|
|
|
|
|
throw new IllegalStateException(
|
|
|
|
|
"Failed to create File from URL '" + url + "'");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void addUrl(List<URL> urls, URL url) {
|
|
|
|
|
try {
|
|
|
|
|
if ("file".equals(url.getProtocol())) {
|
|
|
|
|
addUrlFile(urls, url, new File(getDecodedFile(url)));
|
|
|
|
|
addUrlFile(urls, url, toFile(url));
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
addUrlConnection(urls, url, url.openConnection());
|
|
|
|
@ -85,16 +94,6 @@ class StaticResourceJars {
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private String getDecodedFile(URL url) {
|
|
|
|
|
try {
|
|
|
|
|
return URLDecoder.decode(url.getFile(), "UTF-8");
|
|
|
|
|
}
|
|
|
|
|
catch (UnsupportedEncodingException ex) {
|
|
|
|
|
throw new IllegalStateException(
|
|
|
|
|
"Failed to decode '" + url.getFile() + "' using UTF-8");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void addUrlFile(List<URL> urls, URL url, File file) {
|
|
|
|
|
if ((file.isDirectory() && new File(file, "META-INF/resources").isDirectory())
|
|
|
|
|
|| isResourcesJar(file)) {
|
|
|
|
|