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

Bertrand Delacretaz edited comment on SLING-10810 at 9/14/21, 7:55 AM:
-----------------------------------------------------------------------

I'm not sure exactly where this problem happens, but in general shouldn't we 
throw an exception if code tries to set the status code of a committed response?

The 
[HttpServletResponse.sendError|https://javaee.github.io/javaee-spec/javadocs/javax/servlet/http/HttpServletResponse.html#sendError-int-java.lang.String-]
 method, for example, throws an IllegalStateException if it's called when the 
response is already committed. We might want do to the same.


was (Author: bdelacretaz):
I'm not sure exactly where this problem happens, but in general shouldn't we 
throw an exception if code tries to set multiple response status codes?

The 
[HttpServletResponse.sendError|https://javaee.github.io/javaee-spec/javadocs/javax/servlet/http/HttpServletResponse.html#sendError-int-java.lang.String-]
 method, for example, throws an IllegalStateException if it's called when the 
response is already committed. We might want do to the same.

> new status code should not be set if response is already comitted
> -----------------------------------------------------------------
>
>                 Key: SLING-10810
>                 URL: https://issues.apache.org/jira/browse/SLING-10810
>             Project: Sling
>          Issue Type: Improvement
>          Components: Engine
>    Affects Versions: Engine 2.7.8
>            Reporter: Joerg Hoh
>            Assignee: Joerg Hoh
>            Priority: Major
>             Fix For: Engine 2.7.10
>
>
> If the response is already committed, a new response should not be set, but 
> it should only be warned.
> Otherwise the status code logged in the Sling instance will taken from the 
> ResponseImpl object, which is different from the statuscode which is sent to 
> the client.



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

Reply via email to