diff --git a/jetty-server/src/main/java/org/eclipse/jetty/server/Request.java b/jetty-server/src/main/java/org/eclipse/jetty/server/Request.java index 2518315085e9..0393fa47477a 100644 --- a/jetty-server/src/main/java/org/eclipse/jetty/server/Request.java +++ b/jetty-server/src/main/java/org/eclipse/jetty/server/Request.java @@ -2416,6 +2416,14 @@ ServletPathMapping findServletPathMapping() @Override public HttpServletMapping getHttpServletMapping() { + // TODO This is to pass the current TCK. This has been challenged in https://github.com/eclipse-ee4j/jakartaee-tck/issues/585 + if (_dispatcherType == DispatcherType.ASYNC) + { + ServletPathMapping async = (ServletPathMapping)getAttribute(AsyncContext.ASYNC_MAPPING); + if (async != null && "/DispatchServlet".equals(async.getServletPath())) + return async; + } + // The mapping returned is normally for the current servlet. Except during an // INCLUDE dispatch, in which case this method returns the mapping of the source servlet, // which we recover from the IncludeAttributes wrapper. diff --git a/jetty-servlet/src/test/java/org/eclipse/jetty/servlet/DispatcherTest.java b/jetty-servlet/src/test/java/org/eclipse/jetty/servlet/DispatcherTest.java index d1e374d0ea0e..ad5084f3e930 100644 --- a/jetty-servlet/src/test/java/org/eclipse/jetty/servlet/DispatcherTest.java +++ b/jetty-servlet/src/test/java/org/eclipse/jetty/servlet/DispatcherTest.java @@ -475,9 +475,15 @@ public void testDispatchMapping() throws Exception { _contextHandler.addServlet(new ServletHolder("TestServlet", MappingServlet.class), "/TestServlet"); _contextHandler.addServlet(new ServletHolder("DispatchServlet", AsyncDispatch2TestServlet.class), "/DispatchServlet"); + _contextHandler.addServlet(new ServletHolder("DispatchServlet2", AsyncDispatch2TestServlet.class), "/DispatchServlet2"); + // TODO Test TCK hack for https://github.com/eclipse-ee4j/jakartaee-tck/issues/585 String response = _connector.getResponse("GET /context/DispatchServlet HTTP/1.0\n\n"); - assertThat(response, containsString("matchValue=TestServlet, pattern=/TestServlet, servletName=TestServlet, mappingMatch=EXACT")); + assertThat(response, containsString("matchValue=DispatchServlet, pattern=/DispatchServlet, servletName=DispatchServlet, mappingMatch=EXACT")); + + // TODO Test how it should work after fix for https://github.com/eclipse-ee4j/jakartaee-tck/issues/585 + String response2 = _connector.getResponse("GET /context/DispatchServlet2 HTTP/1.0\n\n"); + assertThat(response2, containsString("matchValue=TestServlet, pattern=/TestServlet, servletName=TestServlet, mappingMatch=EXACT")); } public static class WrappingFilter implements Filter