|
|
@ -28,7 +28,7 @@ import org.springframework.boot.loader.util.AsciiBytes;
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|
* {@link java.net.JarURLConnection} used to support {@link JarFile#getUrl()}.
|
|
|
|
* {@link java.net.JarURLConnection} used to support {@link JarFile#getUrl()}.
|
|
|
|
*
|
|
|
|
*
|
|
|
|
* @author Phillip Webb
|
|
|
|
* @author Phillip Webb
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
class JarURLConnection extends java.net.JarURLConnection {
|
|
|
|
class JarURLConnection extends java.net.JarURLConnection {
|
|
|
@ -51,6 +51,7 @@ class JarURLConnection extends java.net.JarURLConnection {
|
|
|
|
|
|
|
|
|
|
|
|
protected JarURLConnection(URL url, JarFile jarFile) throws MalformedURLException {
|
|
|
|
protected JarURLConnection(URL url, JarFile jarFile) throws MalformedURLException {
|
|
|
|
super(new URL(buildRootUrl(jarFile)));
|
|
|
|
super(new URL(buildRootUrl(jarFile)));
|
|
|
|
|
|
|
|
this.url = url;
|
|
|
|
this.jarFile = jarFile;
|
|
|
|
this.jarFile = jarFile;
|
|
|
|
|
|
|
|
|
|
|
|
String spec = url.getFile();
|
|
|
|
String spec = url.getFile();
|
|
|
@ -59,27 +60,19 @@ class JarURLConnection extends java.net.JarURLConnection {
|
|
|
|
throw new MalformedURLException("no " + SEPARATOR + " found in url spec:"
|
|
|
|
throw new MalformedURLException("no " + SEPARATOR + " found in url spec:"
|
|
|
|
+ spec);
|
|
|
|
+ spec);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
/*
|
|
|
|
if (separator + 2 != spec.length()) {
|
|
|
|
* The superclass constructor creates a jarFileUrl which is equal to the root URL
|
|
|
|
|
|
|
|
* of the containing archive (therefore not unique if we are connecting to
|
|
|
|
|
|
|
|
* multiple nested jars in the same archive). Therefore we need to make something
|
|
|
|
|
|
|
|
* sensible for #getJarFileURL().
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
if (separator + SEPARATOR.length() != spec.length()) {
|
|
|
|
|
|
|
|
this.jarEntryName = decode(spec.substring(separator + 2));
|
|
|
|
this.jarEntryName = decode(spec.substring(separator + 2));
|
|
|
|
this.jarFileUrl = new URL("jar:" + spec.substring(0, separator) + SEPARATOR
|
|
|
|
}
|
|
|
|
+ this.jarEntryName);
|
|
|
|
|
|
|
|
|
|
|
|
String container = spec.substring(0, separator);
|
|
|
|
|
|
|
|
if (container.indexOf(SEPARATOR) == -1) {
|
|
|
|
|
|
|
|
this.jarFileUrl = new URL(container);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
else {
|
|
|
|
this.jarFileUrl = new URL("jar:" + spec.substring(0, separator));
|
|
|
|
this.jarFileUrl = new URL("jar:" + container);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
|
|
|
public URL getJarFileURL() {
|
|
|
|
|
|
|
|
return this.jarFileUrl;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
@Override
|
|
|
|
public void connect() throws IOException {
|
|
|
|
public void connect() throws IOException {
|
|
|
|
if (this.jarEntryName != null) {
|
|
|
|
if (this.jarEntryName != null) {
|
|
|
@ -108,12 +101,22 @@ class JarURLConnection extends java.net.JarURLConnection {
|
|
|
|
return this.jarFile;
|
|
|
|
return this.jarFile;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
|
|
|
public URL getJarFileURL() {
|
|
|
|
|
|
|
|
return this.jarFileUrl;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
@Override
|
|
|
|
public JarEntry getJarEntry() throws IOException {
|
|
|
|
public JarEntry getJarEntry() throws IOException {
|
|
|
|
connect();
|
|
|
|
connect();
|
|
|
|
return (this.jarEntryData == null ? null : this.jarEntryData.asJarEntry());
|
|
|
|
return (this.jarEntryData == null ? null : this.jarEntryData.asJarEntry());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
|
|
|
public String getEntryName() {
|
|
|
|
|
|
|
|
return this.jarEntryName;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
@Override
|
|
|
|
public InputStream getInputStream() throws IOException {
|
|
|
|
public InputStream getInputStream() throws IOException {
|
|
|
|
connect();
|
|
|
|
connect();
|
|
|
|