Commit 6028d92a authored by Phillip Webb's avatar Phillip Webb

Support Windows UNC paths with fat jars

Update `Launcher` and `JarFile` to correctly deal with Windows UNC
paths.

Fixes gh-1641
parent 6009f417
...@@ -142,7 +142,7 @@ public abstract class Launcher { ...@@ -142,7 +142,7 @@ public abstract class Launcher {
ProtectionDomain protectionDomain = getClass().getProtectionDomain(); ProtectionDomain protectionDomain = getClass().getProtectionDomain();
CodeSource codeSource = protectionDomain.getCodeSource(); CodeSource codeSource = protectionDomain.getCodeSource();
URI location = (codeSource == null ? null : codeSource.getLocation().toURI()); URI location = (codeSource == null ? null : codeSource.getLocation().toURI());
String path = (location == null ? null : location.getPath()); String path = (location == null ? null : location.getSchemeSpecificPart());
if (path == null) { if (path == null) {
throw new IllegalStateException("Unable to determine code source archive"); throw new IllegalStateException("Unable to determine code source archive");
} }
......
...@@ -424,6 +424,7 @@ public class JarFile extends java.util.jar.JarFile implements Iterable<JarEntryD ...@@ -424,6 +424,7 @@ public class JarFile extends java.util.jar.JarFile implements Iterable<JarEntryD
if (this.url == null) { if (this.url == null) {
Handler handler = new Handler(this); Handler handler = new Handler(this);
String file = this.rootFile.getFile().toURI() + this.pathFromRoot + "!/"; String file = this.rootFile.getFile().toURI() + this.pathFromRoot + "!/";
file = file.replace("file:////", "file://"); // Fix UNC paths
this.url = new URL("jar", "", -1, file, handler); this.url = new URL("jar", "", -1, file, handler);
} }
return this.url; return this.url;
......
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