Stop using URLResource API that was deprecated in Undertow 1.4.16

Closes gh-9464
pull/8975/merge
Andy Wilkinson 8 years ago
parent 2d3bcae4e1
commit 2e2fde0dcd

@ -48,7 +48,7 @@ class JarResourceManager implements ResourceManager {
public Resource getResource(String path) throws IOException {
URL url = new URL("jar:file:" + this.jarPath + "!"
+ (path.startsWith("/") ? path : "/" + path));
URLResource resource = new URLResource(url, url.openConnection(), path);
URLResource resource = new URLResource(url, path);
if (resource.getContentLength() < 0) {
return null;
}

@ -21,7 +21,6 @@ import java.io.IOException;
import java.net.MalformedURLException;
import java.net.Socket;
import java.net.URL;
import java.net.URLConnection;
import java.nio.charset.Charset;
import java.security.KeyManagementException;
import java.security.KeyStore;
@ -664,15 +663,9 @@ public class UndertowEmbeddedServletContainerFactory
@Override
public Resource getResource(String path) {
for (URL url : this.metaInfResourceJarUrls) {
try {
URL resourceUrl = new URL(url + "META-INF/resources" + path);
URLConnection connection = resourceUrl.openConnection();
if (connection.getContentLength() >= 0) {
return new URLResource(resourceUrl, connection, path);
}
}
catch (IOException ex) {
// Continue
URLResource resource = getMetaInfResource(url, path);
if (resource != null) {
return resource;
}
}
return null;
@ -689,6 +682,21 @@ public class UndertowEmbeddedServletContainerFactory
@Override
public void removeResourceChangeListener(ResourceChangeListener listener) {
}
private URLResource getMetaInfResource(URL resourceJar, String path) {
try {
URL resourceUrl = new URL(resourceJar + "META-INF/resources" + path);
URLResource resource = new URLResource(resourceUrl, path);
if (resource.getContentLength() < 0) {
return null;
}
return resource;
}
catch (MalformedURLException ex) {
return null;
}
}
}

Loading…
Cancel
Save