diff --git a/runtime/runtime_impl_jetty12/src/main/java/com/google/apphosting/runtime/jetty/ee10/ResourceFileServlet.java b/runtime/runtime_impl_jetty12/src/main/java/com/google/apphosting/runtime/jetty/ee10/ResourceFileServlet.java index 93c4f42d..3f687732 100644 --- a/runtime/runtime_impl_jetty12/src/main/java/com/google/apphosting/runtime/jetty/ee10/ResourceFileServlet.java +++ b/runtime/runtime_impl_jetty12/src/main/java/com/google/apphosting/runtime/jetty/ee10/ResourceFileServlet.java @@ -16,8 +16,8 @@ package com.google.apphosting.runtime.jetty.ee10; -import com.google.apphosting.runtime.AppVersion; import com.google.apphosting.runtime.AppEngineConstants; +import com.google.apphosting.runtime.AppVersion; import com.google.apphosting.utils.config.AppYaml; import com.google.common.base.Ascii; import com.google.common.flogger.GoogleLogger; @@ -27,6 +27,9 @@ import jakarta.servlet.http.HttpServlet; import jakarta.servlet.http.HttpServletRequest; import jakarta.servlet.http.HttpServletResponse; +import java.io.IOException; +import java.net.URL; +import java.util.Objects; import org.eclipse.jetty.ee10.servlet.ServletContextHandler; import org.eclipse.jetty.ee10.servlet.ServletHandler; import org.eclipse.jetty.ee10.servlet.ServletMapping; @@ -36,9 +39,6 @@ import org.eclipse.jetty.util.resource.Resource; import org.eclipse.jetty.util.resource.ResourceFactory; -import java.io.IOException; -import java.util.Objects; - /** * {@code ResourceFileServlet} is a copy of {@code org.mortbay.jetty.servlet.DefaultServlet} that * has been trimmed down to only support the subset of features that we want to take advantage of @@ -88,9 +88,8 @@ public void init() throws ServletException { defaultServletName = servletMapping.getServletName(); try { - // TODO: review use of root factory. - resourceBase = - ResourceFactory.root().newResource(context.getResource("/" + appVersion.getPublicRoot())); + URL resourceBaseUrl = context.getResource("/" + appVersion.getPublicRoot()); + resourceBase = (resourceBaseUrl == null) ? null : ResourceFactory.of(chandler).newResource(resourceBaseUrl); } catch (Exception ex) { throw new ServletException(ex); } diff --git a/runtime/runtime_impl_jetty12/src/main/java/com/google/apphosting/runtime/jetty/ee8/ResourceFileServlet.java b/runtime/runtime_impl_jetty12/src/main/java/com/google/apphosting/runtime/jetty/ee8/ResourceFileServlet.java index f79c6ded..4b516e8d 100644 --- a/runtime/runtime_impl_jetty12/src/main/java/com/google/apphosting/runtime/jetty/ee8/ResourceFileServlet.java +++ b/runtime/runtime_impl_jetty12/src/main/java/com/google/apphosting/runtime/jetty/ee8/ResourceFileServlet.java @@ -16,12 +16,13 @@ package com.google.apphosting.runtime.jetty.ee8; -import com.google.apphosting.runtime.AppVersion; import com.google.apphosting.runtime.AppEngineConstants; +import com.google.apphosting.runtime.AppVersion; import com.google.apphosting.utils.config.AppYaml; import com.google.common.base.Ascii; import com.google.common.flogger.GoogleLogger; import java.io.IOException; +import java.net.URL; import java.util.Objects; import javax.servlet.RequestDispatcher; import javax.servlet.ServletContext; @@ -79,8 +80,8 @@ public void init() throws ServletException { welcomeFiles = chandler.getWelcomeFiles(); try { - // TODO: review use of root factory. - resourceBase = ResourceFactory.root().newResource(context.getResource("/" + appVersion.getPublicRoot())); + URL resourceBaseUrl = context.getResource("/" + appVersion.getPublicRoot()); + resourceBase = (resourceBaseUrl == null) ? null : ResourceFactory.of(chandler).newResource(resourceBaseUrl); } catch (Exception ex) { throw new ServletException(ex); }