Fixes #5488 - jetty-dir.css not found when using JPMS.

Moved jetty-dir.css from jetty-util to jetty-server,
so that it can be found by ResourceHandler when using JPMS.

Updated DefaultServlet to call a ResourceHandler method
to retrieve the stylesheet.

Signed-off-by: Simone Bordet <simone.bordet@gmail.com>
This commit is contained in:
Simone Bordet 2020-10-22 16:48:27 +02:00
parent f4c55c65e0
commit 4a4a73df2e
4 changed files with 13 additions and 4 deletions

View File

@ -226,12 +226,17 @@ public class ResourceHandler extends HandlerWrapper implements ResourceFactory,
{
if (_defaultStylesheet == null)
{
_defaultStylesheet = Resource.newResource(this.getClass().getResource("/jetty-dir.css"));
_defaultStylesheet = getDefaultStylesheet();
}
return _defaultStylesheet;
}
}
public static Resource getDefaultStylesheet()
{
return Resource.newResource(ResourceHandler.class.getResource("/jetty-dir.css"));
}
public String[] getWelcomeFiles()
{
return _welcomes;

View File

@ -41,6 +41,7 @@ import org.eclipse.jetty.server.ResourceContentFactory;
import org.eclipse.jetty.server.ResourceService;
import org.eclipse.jetty.server.ResourceService.WelcomeFactory;
import org.eclipse.jetty.server.handler.ContextHandler;
import org.eclipse.jetty.server.handler.ResourceHandler;
import org.eclipse.jetty.util.URIUtil;
import org.eclipse.jetty.util.log.Log;
import org.eclipse.jetty.util.log.Logger;
@ -223,7 +224,7 @@ public class DefaultServlet extends HttpServlet implements ResourceFactory, Welc
}
if (_stylesheet == null)
{
_stylesheet = Resource.newResource(this.getClass().getResource("/jetty-dir.css"));
_stylesheet = ResourceHandler.getDefaultStylesheet();
}
}
catch (Exception e)

View File

@ -202,8 +202,11 @@ public class DemoBaseTests extends AbstractDistributionTest
assertTrue(run.awaitConsoleLogsFor("Started @", 10, TimeUnit.SECONDS));
startHttpClient();
ContentResponse response = client.GET("http://localhost:" + httpPort + "/test/hello");
assertEquals(HttpStatus.OK_200, response.getStatus());
ContentResponse helloResponse = client.GET("http://localhost:" + httpPort + "/test/hello");
assertEquals(HttpStatus.OK_200, helloResponse.getStatus());
ContentResponse cssResponse = client.GET("http://localhost:" + httpPort + "/jetty-dir.css");
assertEquals(HttpStatus.OK_200, cssResponse.getStatus());
}
}