Skip to content

Commit a1b3d33

Browse files
authored
Merge pull request #5491 from eclipse/jetty-9.4.x-5488-jetty-dir.css
Fixes #5488 - jetty-dir.css not found when using JPMS.
2 parents 40acf60 + 4a4a73d commit a1b3d33

File tree

4 files changed

+13
-4
lines changed

4 files changed

+13
-4
lines changed

jetty-server/src/main/java/org/eclipse/jetty/server/handler/ResourceHandler.java

+6-1
Original file line numberDiff line numberDiff line change
@@ -226,12 +226,17 @@ public Resource getStylesheet()
226226
{
227227
if (_defaultStylesheet == null)
228228
{
229-
_defaultStylesheet = Resource.newResource(this.getClass().getResource("/jetty-dir.css"));
229+
_defaultStylesheet = getDefaultStylesheet();
230230
}
231231
return _defaultStylesheet;
232232
}
233233
}
234234

235+
public static Resource getDefaultStylesheet()
236+
{
237+
return Resource.newResource(ResourceHandler.class.getResource("/jetty-dir.css"));
238+
}
239+
235240
public String[] getWelcomeFiles()
236241
{
237242
return _welcomes;

jetty-servlet/src/main/java/org/eclipse/jetty/servlet/DefaultServlet.java

+2-1
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@
4141
import org.eclipse.jetty.server.ResourceService;
4242
import org.eclipse.jetty.server.ResourceService.WelcomeFactory;
4343
import org.eclipse.jetty.server.handler.ContextHandler;
44+
import org.eclipse.jetty.server.handler.ResourceHandler;
4445
import org.eclipse.jetty.util.URIUtil;
4546
import org.eclipse.jetty.util.log.Log;
4647
import org.eclipse.jetty.util.log.Logger;
@@ -222,7 +223,7 @@ public void init()
222223
}
223224
if (_stylesheet == null)
224225
{
225-
_stylesheet = Resource.newResource(this.getClass().getResource("/jetty-dir.css"));
226+
_stylesheet = ResourceHandler.getDefaultStylesheet();
226227
}
227228
}
228229
catch (Exception e)

tests/test-distribution/src/test/java/org/eclipse/jetty/tests/distribution/DemoBaseTests.java

+5-2
Original file line numberDiff line numberDiff line change
@@ -202,8 +202,11 @@ public void testJPMS() throws Exception
202202
assertTrue(run.awaitConsoleLogsFor("Started @", 10, TimeUnit.SECONDS));
203203

204204
startHttpClient();
205-
ContentResponse response = client.GET("http://localhost:" + httpPort + "/test/hello");
206-
assertEquals(HttpStatus.OK_200, response.getStatus());
205+
ContentResponse helloResponse = client.GET("http://localhost:" + httpPort + "/test/hello");
206+
assertEquals(HttpStatus.OK_200, helloResponse.getStatus());
207+
208+
ContentResponse cssResponse = client.GET("http://localhost:" + httpPort + "/jetty-dir.css");
209+
assertEquals(HttpStatus.OK_200, cssResponse.getStatus());
207210
}
208211
}
209212

0 commit comments

Comments
 (0)