Remove assumption that a file URI can be turned into a File
Closes gh-13493
This commit is contained in:
parent
f2cc6e2ef2
commit
fd125b4a4a
|
|
@ -78,15 +78,24 @@ class StaticResourceJars {
|
|||
throw new IllegalStateException(
|
||||
"Failed to create File from URL '" + url + "'");
|
||||
}
|
||||
catch (IllegalArgumentException ex) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
private void addUrl(List<URL> urls, URL url) {
|
||||
try {
|
||||
if ("file".equals(url.getProtocol())) {
|
||||
addUrlFile(urls, url, toFile(url));
|
||||
if (!"file".equals(url.getProtocol())) {
|
||||
addUrlConnection(urls, url, url.openConnection());
|
||||
}
|
||||
else {
|
||||
addUrlConnection(urls, url, url.openConnection());
|
||||
File file = toFile(url);
|
||||
if (file != null) {
|
||||
addUrlFile(urls, url, file);
|
||||
}
|
||||
else {
|
||||
addUrlConnection(urls, url, url.openConnection());
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (IOException ex) {
|
||||
|
|
|
|||
|
|
@ -74,6 +74,14 @@ public class StaticResourceJarsTests {
|
|||
assertThat(staticResourceJarUrls).hasSize(0);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void uncPathsAreTolerated() throws Exception {
|
||||
File jarFile = createResourcesJar("test-resources.jar");
|
||||
List<URL> staticResourceJarUrls = new StaticResourceJars().getUrlsFrom(
|
||||
jarFile.toURI().toURL(), new URL("file://unc.example.com/test.jar"));
|
||||
assertThat(staticResourceJarUrls).hasSize(1);
|
||||
}
|
||||
|
||||
private File createResourcesJar(String name) throws IOException {
|
||||
return createJar(name, (output) -> {
|
||||
JarEntry jarEntry = new JarEntry("META-INF/resources");
|
||||
|
|
|
|||
Loading…
Reference in New Issue