Merge branch '2.0.x'

pull/13540/head
Andy Wilkinson 7 years ago
commit 24dec4807f

@ -78,17 +78,26 @@ class StaticResourceJars {
throw new IllegalStateException( throw new IllegalStateException(
"Failed to create File from URL '" + url + "'"); "Failed to create File from URL '" + url + "'");
} }
catch (IllegalArgumentException ex) {
return null;
}
} }
private void addUrl(List<URL> urls, URL url) { private void addUrl(List<URL> urls, URL url) {
try { try {
if ("file".equals(url.getProtocol())) { if (!"file".equals(url.getProtocol())) {
addUrlFile(urls, url, toFile(url)); addUrlConnection(urls, url, url.openConnection());
}
else {
File file = toFile(url);
if (file != null) {
addUrlFile(urls, url, file);
} }
else { else {
addUrlConnection(urls, url, url.openConnection()); addUrlConnection(urls, url, url.openConnection());
} }
} }
}
catch (IOException ex) { catch (IOException ex) {
throw new IllegalStateException(ex); throw new IllegalStateException(ex);
} }

@ -74,6 +74,14 @@ public class StaticResourceJarsTests {
assertThat(staticResourceJarUrls).hasSize(0); 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 { private File createResourcesJar(String name) throws IOException {
return createJar(name, (output) -> { return createJar(name, (output) -> {
JarEntry jarEntry = new JarEntry("META-INF/resources"); JarEntry jarEntry = new JarEntry("META-INF/resources");

Loading…
Cancel
Save