How RESTeasy resolves @Path conflict

Consider the code above

@Path("a") @Produces("text/plain") public class A { @GET @Path("a") public String getA() { return "a"; } @GET @Path("a") public String getB() { return "b"; } } 

Request http: // host / a / a I always get "b".

What is the strategy for choosing the right method? Any way to get information on several paths to various resources?

+4
source share
1 answer

Further edited in the light of the comment.

I don’t know of any reporting tool in RESTEasy that offers a list of duplicate match patterns in a range of annotated service classes. However, you can address this issue using one of the following methods:

  • grep and awk source code for @Path to create a sortable list of path expressions
  • Use the AnnotationReader implementation to scan your class path as part of a unit test and detect duplicate regular expression patterns.

Edited to better ask a question

RESTEasy uses a regex system for paths and selects the most suitable pattern. In the event of a collision, the last matched is used.

+3
source

All Articles