Skip to content

Commit

Permalink
Fixes #5488 - jetty-dir.css not found when using JPMS.
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
sbordet committed Oct 22, 2020
1 parent f4c55c6 commit 4a4a73d
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -226,12 +226,17 @@ public Resource getStylesheet()
{
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;
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@
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;
Expand Down Expand Up @@ -223,7 +224,7 @@ public void init()
}
if (_stylesheet == null)
{
_stylesheet = Resource.newResource(this.getClass().getResource("/jetty-dir.css"));
_stylesheet = ResourceHandler.getDefaultStylesheet();
}
}
catch (Exception e)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -202,8 +202,11 @@ public void testJPMS() throws Exception
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());
}
}

Expand Down

0 comments on commit 4a4a73d

Please sign in to comment.