Skip to content

Commit 1fc9d38

Browse files
cemophilwebb
authored andcommitted
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
1 parent 4ad5c52 commit 1fc9d38

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

spring-boot/src/main/java/org/springframework/boot/context/embedded/jetty/JettyEmbeddedServletContainerFactory.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@
4040
import org.eclipse.jetty.servlet.ErrorPageErrorHandler;
4141
import org.eclipse.jetty.servlet.ServletHolder;
4242
import org.eclipse.jetty.servlet.ServletMapping;
43+
import org.eclipse.jetty.util.resource.JarResource;
4344
import org.eclipse.jetty.util.resource.Resource;
4445
import org.eclipse.jetty.util.ssl.SslContextFactory;
4546
import org.eclipse.jetty.webapp.AbstractConfiguration;
@@ -259,7 +260,8 @@ private void configureDocumentRoot(WebAppContext handler) {
259260
if (root != null) {
260261
try {
261262
if (!root.isDirectory()) {
262-
Resource resource = Resource.newResource("jar:" + root.toURI() + "!");
263+
Resource resource = JarResource.newJarResource(Resource
264+
.newResource(root));
263265
handler.setBaseResource(resource);
264266
}
265267
else {

0 commit comments

Comments
 (0)