Commit 2e2fde0d authored by Andy Wilkinson's avatar Andy Wilkinson

Stop using URLResource API that was deprecated in Undertow 1.4.16

Closes gh-9464
parent 2d3bcae4
...@@ -48,7 +48,7 @@ class JarResourceManager implements ResourceManager { ...@@ -48,7 +48,7 @@ class JarResourceManager implements ResourceManager {
public Resource getResource(String path) throws IOException { public Resource getResource(String path) throws IOException {
URL url = new URL("jar:file:" + this.jarPath + "!" URL url = new URL("jar:file:" + this.jarPath + "!"
+ (path.startsWith("/") ? path : "/" + path)); + (path.startsWith("/") ? path : "/" + path));
URLResource resource = new URLResource(url, url.openConnection(), path); URLResource resource = new URLResource(url, path);
if (resource.getContentLength() < 0) { if (resource.getContentLength() < 0) {
return null; return null;
} }
......
...@@ -21,7 +21,6 @@ import java.io.IOException; ...@@ -21,7 +21,6 @@ import java.io.IOException;
import java.net.MalformedURLException; import java.net.MalformedURLException;
import java.net.Socket; import java.net.Socket;
import java.net.URL; import java.net.URL;
import java.net.URLConnection;
import java.nio.charset.Charset; import java.nio.charset.Charset;
import java.security.KeyManagementException; import java.security.KeyManagementException;
import java.security.KeyStore; import java.security.KeyStore;
...@@ -664,15 +663,9 @@ public class UndertowEmbeddedServletContainerFactory ...@@ -664,15 +663,9 @@ public class UndertowEmbeddedServletContainerFactory
@Override @Override
public Resource getResource(String path) { public Resource getResource(String path) {
for (URL url : this.metaInfResourceJarUrls) { for (URL url : this.metaInfResourceJarUrls) {
try { URLResource resource = getMetaInfResource(url, path);
URL resourceUrl = new URL(url + "META-INF/resources" + path); if (resource != null) {
URLConnection connection = resourceUrl.openConnection(); return resource;
if (connection.getContentLength() >= 0) {
return new URLResource(resourceUrl, connection, path);
}
}
catch (IOException ex) {
// Continue
} }
} }
return null; return null;
...@@ -689,6 +682,21 @@ public class UndertowEmbeddedServletContainerFactory ...@@ -689,6 +682,21 @@ public class UndertowEmbeddedServletContainerFactory
@Override @Override
public void removeResourceChangeListener(ResourceChangeListener listener) { 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;
}
} }
} }
......
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