users@jsr311.java.net

Re: Telling ExceptionMapper to exclude exceptions

From: Paul Sandoz <Paul.Sandoz_at_Sun.COM>
Date: Tue, 14 Oct 2008 13:03:07 +0200

On Oct 14, 2008, at 9:09 AM, Paul Sandoz wrote:

>
> On Oct 14, 2008, at 2:37 AM, cowwoc wrote:
>
>> On Oct 13, 2008, at 7:46 PM, Paul Sandoz wrote:
>>
>>> On Oct 13, 2008, at 7:15 PM, Marc Hadley wrote:
>>>
>>>> On Oct 13, 2008, at 12:07 PM, cowwoc wrote:
>>>>>
>>>>> Under Jersey, ExceptionMapper<RuntimeException> gets called
>>>>> even for Jersey internal exceptions, such as
>>>>> *com.sun.jersey.api.container.ContainerException.
>>>>
>>>> Does the stack trace include a resource or provider method ? I'm
>>>> wondering about the origin of the exception. You should only be
>>>> seeing exceptions that originate in the context of a resource or
>>>> provider method or in the creation of a resource method
>>>> parameter, field or property value.
>>>>
>>>
>>> I think there is a bug in Jersey it does not differentiate based
>>> on where the exception originates.
>>>
>>> Paul.
>>
>>
>> Section 4.4 of the specification reads:
>>
>> When a resource class or provider method throws an exception, the
>> JAX-RS runtime will attempt to map the
>> exception to a suitable HTTP response[...]
>>
>> so my interpretation is the same as yours, that Jersey should not
>> be passing these exceptions to ExceptionMapper. Is there a TCK for
>> JSR311 to ensure that other implementations do not make this mistake?
>>
>
> There is, but currently it is not covering this aspect. The scope of
> the TCK will be improved.
>

BTW i am not sure it is possible to test in the negative, namely to
induce an exception in the JAX-RS implementation that does not
originate from a resource class or provider in a platform independent
manner.

Paul.