[ 
https://issues.apache.org/jira/browse/FELIX-6434?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Carsten Ziegeler resolved FELIX-6434.
-------------------------------------
    Resolution: Fixed

Checking the state of the response now in the dispatcher before calling 
senderror
https://github.com/apache/felix-dev/commit/abf81ce9b54d5efae0abea8d84c668ab3bec86d2

> errorhandler can commit the response wice
> -----------------------------------------
>
>                 Key: FELIX-6434
>                 URL: https://issues.apache.org/jira/browse/FELIX-6434
>             Project: Felix
>          Issue Type: Improvement
>          Components: HTTP Service
>    Affects Versions: http.base-4.1.2, http.bridge-4.1.2, http.jetty-4.1.10
>            Reporter: Joerg Hoh
>            Assignee: Carsten Ziegeler
>            Priority: Major
>             Fix For: http.base-4.1.4, http.jetty-4.1.12, http.bridge-4.1.4
>
>
> We saw this exception in our logs:
> {code}
> 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)
> {code}
> 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--



--
This message was sent by Atlassian Jira
(v8.3.4#803005)

Reply via email to