users@jax-rs-spec.java.net

[jax-rs-spec users] Re: Exception mapper ambiguity

From: Christian Kaltepoth <christian_at_kaltepoth.de>
Date: Wed, 27 Jul 2016 06:39:22 +0200

Hi Sebastian,

thanks for your response. I agree that there are other candidates which
need support for ordering. I ran into such ambiguity issues with
ExceptionMapper and ParamConverterProvider. The fact that ambiguity is not
handled at all for these extension points is currently blocking progress
for some features in JSR 371. So it would be great if JAX-RS could improve
the selection algorithm for these to support some kind of ordering. And I
think @Priority would be a perfect fit.

As far as I know Reader/WriterInterceptors already support ordering via
@Priority. See section 6.6 of the spec. Not sure about
MessageBodyReaders/Writers
to be honest.

Christian



2016-07-26 18:06 GMT+02:00 Sebastian Daschner <java_at_sebastian-daschner.de>:

> Hi Christian,
>
> Sorry for the late response.
>
> +1 for being able to specify the exception mappers via @Priority. But if
> we add this feature I think we should at least think of other potential
> candidates for ordering / selecting as well such as
> Reader/WriterInterceptors or MessageBodyReaders/Writers. WDYT?
>
> Cheers,
> Sebastian
> On 07/18/2016 09:06 AM, Christian Kaltepoth wrote:
>
> Hey all,
>
> I just stumbled upon a minor inaccuracy in the specification. The matching
> algorithm of an exception to an exception mapper is defined like this:
>
> When choosing an exception mapping provider to map an exception, an
>> implementation MUST use the provider whose generic type is the nearest
>> superclass of the exception.
>
>
> That's all. So the spec currently does not define which mapper is selected
> if there are multiple ones for the same exception type. This is problematic
> if there are multiple ones provided by the JAX-RS implementation, 3rd party
> libraries or by the application itself.
>
> This could be fixed if the JAX-RS specifies that in these cases the
> @Priority annotation can be used to order the mappers. I think this
> pattern is widely adopted in Java EE. We also use @Priority for ordering
> SPIs in MVC 1.0.
>
> Thoughts?
>
> Christian
>
>
> --
> Christian Kaltepoth
> Blog: http://blog.kaltepoth.de/
> Twitter: http://twitter.com/chkal
> GitHub: https://github.com/chkal
>
>
>


-- 
Christian Kaltepoth
Blog: http://blog.kaltepoth.de/
Twitter: http://twitter.com/chkal
GitHub: https://github.com/chkal