Question

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";
    }
}

Requesting http://host/a/a i always get "b".

What is the strategy to select the appropiated method ? Any way to get informed about multiple paths to diferent resources ?

Was it helpful?

Solution

Further edited in light of the comment

I don't know of any reporting tool within RESTEasy that offers a list of duplicated matching patterns across a range of annotated service classes. However, you could approach this problem using one of the following methods:

  1. grep and awk the source code for @Path to generate a sortable list of path expressions
  2. Use an AnnotationReader implementation to scan over your classpath as part of a unit test and have it detect duplicated regex patterns.

Edited to better target the question

RESTEasy uses a regex based system for paths and selects the most closely matching pattern. In the event of a collision the last one matched is used.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top