New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Handling of multiple exception mappers for same exception type #537
Comments
@glassfishrobot Commented |
@glassfishrobot Commented |
@glassfishrobot Commented |
@pavelbucek Commented I mean - custom exception mapper with same distance (exception type distance) should always have a priority. Custom exception mapper is anything NOT provided by the JAX-RS implementation. |
@chkal Commented Why not give built-in mappers also a (very low) priority and use the same ordering logic if the user provides a mapper with the same exception type distance as a built-in mapper. This way users can easily override the JAX-RS default behavior for exceptions like |
@pavelbucek Commented |
@pavelbucek Commented keeping this issue open since we need to update spec document and maybe some javadocs. |
@ggam Commented In that case, what if there's a library on the server classpath containing some mappers. Would they be affected by priorities or would they be considered "built-in" for the JAX-RS runtime? For the end user, those would seem like "built-in", but I don't think the runtime should treat them as such. I'm with @chkal in that taking priority into account for every mapper is the best way to go. When no @priority is defined, the implementation would resort to the former behavior. |
@chkal Commented Looks like the latest Jersey 2.26-b04 includes this feature (jersey/jersey@904ed19). I'll give it a try in the next days. |
@pavelbucek Commented |
|
The matching algorithm of an exception type to an exception mapper is defined like this:
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 specification mandates 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.
Affected Versions
[2.1]
The text was updated successfully, but these errors were encountered: