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

Felix Meschberger commented on SLING-1842:
------------------------------------------

I am not sure (and may be completely wrong), but the error handler does a reset 
(buffer) first before getting the writer. So I would assume the writer would be 
available.

This may of course be wrong, in which case I am ok with a similar patch...

(1) The DefaultErrorHandler.sendIntro is wrong any way: the response content 
type with character encoding must be set _before_ getting the writer (required 
by the Servlet API Spec)

(2) We might want to build this special handling into the private 
SlingRequestProcessImpl.handleError method by providing a response wrapper 
which contains the special writer handling (and then using the response 
character set to properly setup the outputstream based writer)

> Maybe we shouldn't throw at all if the writer can't be retrieved?

This is mandated by the servlet API spec, which says getWriter must throw an 
IllegalStateException if the output stream has already been retrieved

> IllegalStateException in DefaultErrorHandlerServlet when 
> HttpServletResponse.getOutputStream() already called
> -------------------------------------------------------------------------------------------------------------
>
>                 Key: SLING-1842
>                 URL: https://issues.apache.org/jira/browse/SLING-1842
>             Project: Sling
>          Issue Type: Bug
>          Components: Servlets
>            Reporter: Carl Hall
>         Attachments: SLING-1842.diff
>
>
> When getOutputStream() has been called, DefaultErrorHandlerServlet is unable 
> to write the error page and dumps an exception in the logs.  It'd be nice if 
> it failed a bit more gracefully.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.

Reply via email to