Uploaded image for project: 'Felix'
  1. Felix
  2. FELIX-6434

errorhandler can commit the response wice

    XMLWordPrintableJSON

Details

    Description

      We saw this exception in our logs:

      28.05.2021 06:35:32.758 ERROR [qtp1872055084-43557] org.apache.felix.http.jetty Exception while processing request to /crx/de/endorsed/extjs/ext-all-debug.js (org.eclipse.jetty.io.EofException)
      org.eclipse.jetty.io.EofException: null
      at org.eclipse.jetty.io.ChannelEndPoint.flush(ChannelEndPoint.java:279) [org.apache.felix.http.jetty:4.1.2.T2020102214]
      at org.eclipse.jetty.io.WriteFlusher.flush(WriteFlusher.java:422) [org.apache.felix.http.jetty:4.1.2.T2020102214]
      at org.eclipse.jetty.io.WriteFlusher.completeWrite(WriteFlusher.java:378) [org.apache.felix.http.jetty:4.1.2.T2020102214]
      at org.eclipse.jetty.io.ChannelEndPoint$2.run(ChannelEndPoint.java:119) [org.apache.felix.http.jetty:4.1.2.T2020102214]
      java.lang.IllegalStateException: Committed
      at org.eclipse.jetty.server.HttpChannel.resetBuffer(HttpChannel.java:917) [org.apache.felix.http.jetty:4.1.2.T2020102214]
      at org.eclipse.jetty.server.HttpOutput.resetBuffer(HttpOutput.java:1418) [org.apache.felix.http.jetty:4.1.2.T2020102214]
      at org.eclipse.jetty.server.Response.resetBuffer(Response.java:1180) [org.apache.felix.http.jetty:4.1.2.T2020102214]
      at javax.servlet.ServletResponseWrapper.resetBuffer(ServletResponseWrapper.java:195) [org.apache.felix.http.servlet-api:1.1.2]
      at org.apache.felix.http.base.internal.dispatch.ServletResponseWrapper.sendError(ServletResponseWrapper.java:67) [org.apache.felix.http.jetty:4.1.2.T2020102214]
      at org.apache.felix.http.base.internal.dispatch.ServletResponseWrapper.sendError(ServletResponseWrapper.java:61) [org.apache.felix.http.jetty:4.1.2.T2020102214]
      at org.apache.felix.http.base.internal.dispatch.Dispatcher$1.doFilter(Dispatcher.java:155) [org.apache.felix.http.jetty:4.1.2.T2020102214]
      at org.apache.felix.http.base.internal.whiteboard.WhiteboardManager$2.doFilter(WhiteboardManager.java:1002) [org.apache.felix.http.jetty:4.1.2.T2020102214]
      at com.adobe.granite.auth.oauth.impl.OAuthCallbackFilter.doFilter(OAuthCallbackFilter.java:69) [com.adobe.granite.auth.oauth:1.7.2]
      at org.apache.felix.http.base.internal.handler.PreprocessorHandler.handle(PreprocessorHandler.java:137) [org.apache.felix.http.jetty:4.1.2.T2020102214]
      at org.apache.felix.http.base.internal.whiteboard.WhiteboardManager$2.doFilter(WhiteboardManager.java:1008) [org.apache.felix.http.jetty:4.1.2.T2020102214]
      at org.eclipse.jetty.util.thread.strategy.EatWhatYouKill.run(EatWhatYouKill.java:129) [org.apache.felix.http.jetty:4.1.2.T2020102214]
      at org.eclipse.jetty.util.thread.ReservedThreadExecutor$ReservedThread.run(ReservedThreadExecutor.java:375) [org.apache.felix.http.jetty:4.1.2.T2020102214]
      at org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:806) [org.apache.felix.http.jetty:4.1.2.T2020102214]
      at org.eclipse.jetty.util.thread.QueuedThreadPool$Runner.run(QueuedThreadPool.java:938) [org.apache.felix.http.jetty:4.1.2.T2020102214]
      at java.base/java.lang.Thread.run(Thread.java:834)
      

      Checking the code it seems that the ServletResponseWrapper.sendError() [1] does a resetBuffer(), which according to its javadoc [2] can throw an IllegalStateException if the response has been already committed.

      Therefor the call to resetBuffer() should be guarded by a check of isCommitted() and invoke it only in case the response is not yet committed.

      Probably it also makes sense to not to set the statuscode because it also does not have any effect anymore.

      [1] https://github.com/apache/felix-dev/blob/master/http/base/src/main/java/org/apache/felix/http/base/internal/dispatch/ServletResponseWrapper.java#L65
      [2] https://javaee.github.io/javaee-spec/javadocs/javax/servlet/ServletResponse.html#resetBuffer--

      Attachments

        Activity

          People

            cziegeler Carsten Ziegeler
            joerghoh Joerg Hoh
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: