[ https://issues.apache.org/jira/browse/SLING-12003?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17754501#comment-17754501 ]
Carsten Ziegeler edited comment on SLING-12003 at 8/15/23 9:00 AM: ------------------------------------------------------------------- So we could add the isCommitted() check around the flush. No need to get into the async business :) was (Author: cziegeler): So we could the isCommitted() check around the flush. No need to get into the async business :) > The RequestDispatcher should flush the buffer on forward only if the buffer > hasn't already been closed > ------------------------------------------------------------------------------------------------------ > > Key: SLING-12003 > URL: https://issues.apache.org/jira/browse/SLING-12003 > Project: Sling > Issue Type: Improvement > Components: Engine > Affects Versions: Engine 2.2.10 > Reporter: Radu Cotescu > Priority: Major > Fix For: Engine 2.15.6 > > > The {{SlingRequestDispatcher#forward}} call [0] attempts to close the > response buffer even if this has already been closed by the servlet to which > the request was originally forwarded. The Servlet Specification [1] mentions > the following in section 9.4: > {quote}Before the forward method of the RequestDispatcher interface returns > without exception, the response content must be sent and committed, and > closed by the servlet container, unless the request was put into the > asynchronous mode. > {quote} > As such, the {{RequestDispatcher#forward}} implementation should indeed make > sure the response is committed, but it's not necessarily the only one that > must commit the response. Jetty seems to have the same understanding [2], > where the close is performed only if the response hasn't already been > committed and the request is not async. > [0] - > [https://github.com/apache/sling-org-apache-sling-engine/blob/368690a2a81fd8a121e62767fcd32b63936a65b8/src/main/java/org/apache/sling/engine/impl/request/SlingRequestDispatcher.java#L125-L128] > [1] - > [https://download.oracle.com/otn-pub/jcp/servlet-3_1-fr-spec/servlet-3_1-final.pdf] > [2] - > [https://github.com/eclipse/jetty.project/blob/jetty-11.0.x/jetty-server/src/main/java/org/eclipse/jetty/server/Dispatcher.java#L218] > > -- This message was sent by Atlassian Jira (v8.20.10#820010)