You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@sling.apache.org by Antonio Sanso <as...@adobe.com> on 2013/02/01 12:08:05 UTC

Sling Error handling

Hi *,

while working on SLING-2718 [0] I have noticed something that made me wonder.
In particular if you see [1] I had to comment one line of my test in order to pass it


        public void test_500_errorhandling() throws IOException{
                final String expected = "Internal Server Error (500) - custom error page";
                final String url =  testNodePath +SELECTOR_500+".html";
                assertContains(getContent(url, CONTENT_TYPE_HTML,null,500), expected);
                //assertNotContains(getContent(url, CONTENT_TYPE_HTML,null,200), "All good");
        }

In a nutshell it seems that 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 "show" both:

- the error page 500.jsp
- and the the extra output (e.g. All good)

Sorry if the questions sounds silly but is this normal or I might have hit some bug?

Regards

Antonio


[0]  https://issues.apache.org/jira/browse/SLING-2718
[1] 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

Re: Sling Error handling

Posted by Antonio Sanso <as...@adobe.com>.
On Feb 5, 2013, at 8:17 PM, Carsten Ziegeler wrote:

> I think we should create an issue for this to keep track of the problem.

Thanks Carsten, I have created https://issues.apache.org/jira/browse/SLING-2724

Regards

Antonio

> 
> Carsten
> 
> 2013/2/1 Carsten Ziegeler <cz...@apache.org>:
>> Hi,
>> 
>> if you call sendError writing output is not allowed. From 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."
>> 
>> As it seems that Sling is handling the sendError call (to invoke the
>> error script) it should throw an exception when "All good" is tried to
>> be written..which results in calling the error script :)
>> 
>> Regards
>> Carsten
>> 
>> 2013/2/1 Antonio Sanso <as...@adobe.com>:
>>> Hi *,
>>> 
>>> while working on SLING-2718 [0] I have noticed something that made me wonder.
>>> In particular if you see [1] I had to comment one line of my test in order to pass it
>>> 
>>> 
>>>        public void test_500_errorhandling() throws IOException{
>>>                final String expected = "Internal Server Error (500) - custom error page";
>>>                final String url =  testNodePath +SELECTOR_500+".html";
>>>                assertContains(getContent(url, CONTENT_TYPE_HTML,null,500), expected);
>>>                //assertNotContains(getContent(url, CONTENT_TYPE_HTML,null,200), "All good");
>>>        }
>>> 
>>> In a nutshell it seems that 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 "show" both:
>>> 
>>> - the error page 500.jsp
>>> - and the the extra output (e.g. All good)
>>> 
>>> Sorry if the questions sounds silly but is this normal or I might have hit some bug?
>>> 
>>> Regards
>>> 
>>> Antonio
>>> 
>>> 
>>> [0]  https://issues.apache.org/jira/browse/SLING-2718
>>> [1] 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
>> 
>> 
>> 
>> --
>> Carsten Ziegeler
>> cziegeler@apache.org
> 
> 
> 
> -- 
> Carsten Ziegeler
> cziegeler@apache.org


Re: Sling Error handling

Posted by Carsten Ziegeler <cz...@apache.org>.
I think we should create an issue for this to keep track of the problem.

Carsten

2013/2/1 Carsten Ziegeler <cz...@apache.org>:
> Hi,
>
> if you call sendError writing output is not allowed. From 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."
>
> As it seems that Sling is handling the sendError call (to invoke the
> error script) it should throw an exception when "All good" is tried to
> be written..which results in calling the error script :)
>
> Regards
> Carsten
>
> 2013/2/1 Antonio Sanso <as...@adobe.com>:
>> Hi *,
>>
>> while working on SLING-2718 [0] I have noticed something that made me wonder.
>> In particular if you see [1] I had to comment one line of my test in order to pass it
>>
>>
>>         public void test_500_errorhandling() throws IOException{
>>                 final String expected = "Internal Server Error (500) - custom error page";
>>                 final String url =  testNodePath +SELECTOR_500+".html";
>>                 assertContains(getContent(url, CONTENT_TYPE_HTML,null,500), expected);
>>                 //assertNotContains(getContent(url, CONTENT_TYPE_HTML,null,200), "All good");
>>         }
>>
>> In a nutshell it seems that 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 "show" both:
>>
>> - the error page 500.jsp
>> - and the the extra output (e.g. All good)
>>
>> Sorry if the questions sounds silly but is this normal or I might have hit some bug?
>>
>> Regards
>>
>> Antonio
>>
>>
>> [0]  https://issues.apache.org/jira/browse/SLING-2718
>> [1] 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
>
>
>
> --
> Carsten Ziegeler
> cziegeler@apache.org



-- 
Carsten Ziegeler
cziegeler@apache.org

Re: Sling Error handling

Posted by Carsten Ziegeler <cz...@apache.org>.
Hi,

if you call sendError writing output is not allowed. From 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."

As it seems that Sling is handling the sendError call (to invoke the
error script) it should throw an exception when "All good" is tried to
be written..which results in calling the error script :)

Regards
Carsten

2013/2/1 Antonio Sanso <as...@adobe.com>:
> Hi *,
>
> while working on SLING-2718 [0] I have noticed something that made me wonder.
> In particular if you see [1] I had to comment one line of my test in order to pass it
>
>
>         public void test_500_errorhandling() throws IOException{
>                 final String expected = "Internal Server Error (500) - custom error page";
>                 final String url =  testNodePath +SELECTOR_500+".html";
>                 assertContains(getContent(url, CONTENT_TYPE_HTML,null,500), expected);
>                 //assertNotContains(getContent(url, CONTENT_TYPE_HTML,null,200), "All good");
>         }
>
> In a nutshell it seems that 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 "show" both:
>
> - the error page 500.jsp
> - and the the extra output (e.g. All good)
>
> Sorry if the questions sounds silly but is this normal or I might have hit some bug?
>
> Regards
>
> Antonio
>
>
> [0]  https://issues.apache.org/jira/browse/SLING-2718
> [1] 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



-- 
Carsten Ziegeler
cziegeler@apache.org