Fix potential Jetty MalformedURLException

Update JettyEmbeddedServletContainerFactory to use the JarResource
class to create the base resource. This prevents a potential
"java.lang.NullPointerException: no !/ in spec" error which can occur
when using shaded executable jars.

Fixes gh-2245
pull/2280/merge
cemo 10 years ago committed by Phillip Webb
parent 4ad5c52dd7
commit 1fc9d38396

@ -40,6 +40,7 @@ import org.eclipse.jetty.server.handler.ErrorHandler;
import org.eclipse.jetty.servlet.ErrorPageErrorHandler;
import org.eclipse.jetty.servlet.ServletHolder;
import org.eclipse.jetty.servlet.ServletMapping;
import org.eclipse.jetty.util.resource.JarResource;
import org.eclipse.jetty.util.resource.Resource;
import org.eclipse.jetty.util.ssl.SslContextFactory;
import org.eclipse.jetty.webapp.AbstractConfiguration;
@ -259,7 +260,8 @@ public class JettyEmbeddedServletContainerFactory extends
if (root != null) {
try {
if (!root.isDirectory()) {
Resource resource = Resource.newResource("jar:" + root.toURI() + "!");
Resource resource = JarResource.newJarResource(Resource
.newResource(root));
handler.setBaseResource(resource);
}
else {

Loading…
Cancel
Save