Uploaded image for project: 'Sling'
  1. Sling
  2. SLING-12003

The RequestDispatcher should flush the buffer on forward only if the buffer hasn't already been closed

    XMLWordPrintableJSON

Details

    • Improvement
    • Status: Closed
    • Major
    • Resolution: Fixed
    • Engine 2.2.10
    • Engine 2.15.6
    • Engine
    • None

    Description

      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:

      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.

      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

       

       

      Attachments

        Issue Links

          Activity

            People

              radu Radu Cotescu
              radu Radu Cotescu
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: