Jetty request is wrapped when filtering on jaxrs resource or servlet
@@ -78,7 +78,7 @@ class JDiscFilterInvokerFilter implements Filter {
private void runChainAndResponseFilters(URI uri, HttpServletRequest request, HttpServletResponse response, FilterChain chain) throws IOException, ServletException {
Optional<OneTimeRunnable> responseFilterInvoker =
- jDiscContext.filterResolver.resolveResponseFilter((Request)request, uri)
+ jDiscContext.filterResolver.resolveResponseFilter(toJettyRequest(request), uri)
.map(responseFilter ->
new OneTimeRunnable(() ->
filterInvoker.invokeResponseFilterChain(responseFilter, uri, request, response)));
@@ -108,7 +108,7 @@ class JDiscFilterInvokerFilter implements Filter {
private HttpServletRequest runRequestFilterWithMatchingBinding(AtomicReference<Boolean> responseReturned, URI uri, HttpServletRequest request, HttpServletResponse response) throws IOException {
try {
- RequestFilter requestFilter = jDiscContext.filterResolver.resolveRequestFilter((Request)request, uri).orElse(null);
+ RequestFilter requestFilter = jDiscContext.filterResolver.resolveRequestFilter(toJettyRequest(request), uri).orElse(null);
if (requestFilter == null)
return request;
@@ -135,13 +135,20 @@ class JDiscFilterInvokerFilter implements Filter {
final AccessLogEntry accessLogEntry = null; // Not used in this context.
return new HttpRequestDispatch(jDiscContext,
accessLogEntry,
- getConnector((Request)request).createRequestMetricContext(request, Map.of()),
+ getConnector(toJettyRequest(request)).createRequestMetricContext(request, Map.of()),
request, response);
} catch (IOException e) {
throw throwUnchecked(e);
}
}
+ private static Request toJettyRequest(HttpServletRequest request) {
+ if (request instanceof com.yahoo.jdisc.http.servlet.ServletRequest) {
+ return (Request) ((com.yahoo.jdisc.http.servlet.ServletRequest)request).getRequest();
+ }
+ return (Request) request;
+ }
+
@Override
public void destroy() {}
