[ 
https://issues.apache.org/jira/browse/SLING-2724?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13574259#comment-13574259
 ] 

Carsten Ziegeler commented on SLING-2724:
-----------------------------------------

Not sure, what happens if we call close() - I remember some years ago calling 
close() on the writer to throw an exception in some app server; but that might 
have been a bug there. Afaik, it's not specified what happens if you call close 
(other than the javadocs for the writer).
I think we could handle this somehow in our response wrapper - the first sling 
response wrapper we create, set a flag if an error handler has been called and 
then throw an exception if content is written after the error handler has been 
called.
However, we have to be aware that this is a change in behaviour: previously if 
sendError is called and content is written after that, the content of the error 
handler plus the additional content is sent to the client.
Now, if we throw an exception like IllegalStateException - this is escalated up 
to the servlet engine and the engine is sending an error response - or if we 
don't throw an exception (although we should if we follow the spec) we could 
ignore any additional output (fail gracefully).
                
> Error handling doesn't respect servlet spec
> -------------------------------------------
>
>                 Key: SLING-2724
>                 URL: https://issues.apache.org/jira/browse/SLING-2724
>             Project: Sling
>          Issue Type: Bug
>          Components: Servlets
>            Reporter: Antonio Sanso
>
> If there is some servlet that is sending a 500 error 
> (response.sendError(500)) and output something after e.g. "All good" (maybe 
> this is the wrong part...) and a 500.jsp exists, Sling will "shows" both:
> - the error page 500.jsp
>  - and the the extra output (e.g. All good) 
> This seems to violate the spec:
> "These methods [sendError, sendRedirect] will have the side effect of 
> committing the response, if it has not already been committed, and 
> terminating it. No further output to the client should be made by the servlet 
> after these methods are called. If data is written to the response after 
> these methods are called, the data is ignored."
> Integration test showing the issue in [0]
> Mailing list thread in [1]
> [0] 
> https://svn.apache.org/repos/asf/sling/trunk/launchpad/integration-tests/src/main/java/org/apache/sling/launchpad/webapp/integrationtest/servlets/resolver/errorhandler/ErrorHandlingTest.java
> [1] sling.markmail.org/thread/k2t7p5mhi4hgelwb

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira

Reply via email to