diff --git a/jetty-server/src/main/java/org/eclipse/jetty/server/handler/ResourceHandler.java b/jetty-server/src/main/java/org/eclipse/jetty/server/handler/ResourceHandler.java index b5e19ee9461..9b5f4ca3e38 100644 --- a/jetty-server/src/main/java/org/eclipse/jetty/server/handler/ResourceHandler.java +++ b/jetty-server/src/main/java/org/eclipse/jetty/server/handler/ResourceHandler.java @@ -91,15 +91,15 @@ public class ResourceHandler extends HandlerWrapper implements ResourceFactory,W if (_welcomes == null) return null; - String welcome_servlet = null; for (int i = 0; i < _welcomes.length; i++) { String welcome_in_context = URIUtil.addPaths(pathInContext,_welcomes[i]); Resource welcome = getResource(welcome_in_context); if (welcome != null && welcome.exists()) - return _welcomes[i]; + return welcome_in_context; } - return welcome_servlet; + // not found + return null; } diff --git a/jetty-server/src/test/java/org/eclipse/jetty/server/handler/ResourceHandlerTest.java b/jetty-server/src/test/java/org/eclipse/jetty/server/handler/ResourceHandlerTest.java index e56cfb81b80..2a4601ef605 100644 --- a/jetty-server/src/test/java/org/eclipse/jetty/server/handler/ResourceHandlerTest.java +++ b/jetty-server/src/test/java/org/eclipse/jetty/server/handler/ResourceHandlerTest.java @@ -254,7 +254,7 @@ public class ResourceHandlerTest HttpTester.Response response = HttpTester.parseResponse( _local.getResponse("GET /resource/directory/ HTTP/1.0\r\n\r\n")); assertThat(response.getStatus(),equalTo(302)); - assertThat(response.get(LOCATION),containsString("/resource/welcome.txt")); + assertThat(response.get(LOCATION),containsString("/resource/directory/welcome.txt")); } finally {