cziegeler commented on code in PR #62: URL: https://github.com/apache/sling-org-apache-sling-engine/pull/62#discussion_r2122756575
########## src/main/java/org/apache/sling/engine/impl/filter/ErrorFilterChain.java: ########## @@ -117,8 +120,30 @@ public void doFilter(final ServletRequest request, final ServletResponse respons } return; } + // reset the response to clear headers and body - response.reset(); + if (response instanceof SlingHttpServletResponseImpl) { + SlingHttpServletResponseImpl slingResponse = (SlingHttpServletResponseImpl) response; + /* + * Below section stores the original dispatching info for later restoration. + * This is necessary to ensure that the dispatching info is set to ERROR + * while the error is being handled and the response is reset, but restored to + * its original state after the error handling is complete. This is important + * for correct request processing and to avoid side effects on subsequent + * filters or request processing steps. + */ + DispatchingInfo originalInfo = null; + try { + originalInfo = slingResponse.getRequestData().getDispatchingInfo(); + final DispatchingInfo dispatchInfo = new DispatchingInfo(DispatcherType.ERROR); + slingResponse.getRequestData().setDispatchingInfo(dispatchInfo); + response.reset(); Review Comment: The super.doFilter() needs to be included here as well. The actual error handler might want to set a content type or any other header which otherwise might be ignored -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: dev-unsubscr...@sling.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org