You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@sling.apache.org by "Joerg Hoh (Jira)" <ji...@apache.org> on 2021/06/10 06:21:00 UTC
[jira] [Commented] (SLING-10478) SlingServletResolver#handleError
should not attempt to flush/close an already closed response writer
[ https://issues.apache.org/jira/browse/SLING-10478?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17360584#comment-17360584 ]
Joerg Hoh commented on SLING-10478:
-----------------------------------
[~enorman] oh, this one is nagging me for months ... thanks for spotting and fixing it.
> SlingServletResolver#handleError should not attempt to flush/close an already closed response writer
> ----------------------------------------------------------------------------------------------------
>
> Key: SLING-10478
> URL: https://issues.apache.org/jira/browse/SLING-10478
> Project: Sling
> Issue Type: Bug
> Reporter: Eric Norman
> Assignee: Eric Norman
> Priority: Major
> Fix For: Servlets Resolver 2.7.16
>
> Time Spent: 20m
> Remaining Estimate: 0h
>
> In SlingServletResolver#handleError if the errorHandler servlet has already closed the response writer, then it should not attempt to flush/close it again.
> The attempt to flush/close the already closed writer after the errorHandler servlet is invoked can result in a WriterAlreadyClosedException being thrown which can fill up the logs with noise.
> For example, if a custom error handler servlet is generating a JSON error response using a JsonGenerator that writes to the response writer, then closing the JsonGenerator object would also close the response writer.
> The logs have exceptions like this:
> {noformat}
> java.io.IOException: Error handler failed: org.apache.sling.engine.impl.SlingHttpServletResponseImpl$WriterAlreadyClosedException
> at org.apache.sling.servlets.resolver.internal.SlingServletResolver.handleError(SlingServletResolver.java:655) [org.apache.sling.servlets.resolver:2.7.14]
> at org.apache.sling.servlets.resolver.internal.SlingServletResolver.handleError(SlingServletResolver.java:328) [org.apache.sling.servlets.resolver:2.7.14]
> at org.apache.sling.engine.impl.DefaultErrorHandler.handleError(DefaultErrorHandler.java:97) [org.apache.sling.engine:2.7.6]
> ...{noformat}
> Expected:
> Track whether the response writer is closed and skip the flush/close calls if it is already closed.
>
--
This message was sent by Atlassian Jira
(v8.3.4#803005)