Details
-
Bug
-
Resolution: Done
-
Major
-
None
-
2.3-beta-1
-
None
Description
Covariant return types on parameterized subresource locator implementation methods generate exceptions:
org.jboss.resteasy.spi.LoggableFailure: You cannot have 2 locators for same path:
{path}at org.jboss.resteasy.core.registry.RootSegment.addPath(RootSegment.java:67)
Example:
public static interface Root { @Path("sub/\{path}") public Sub getSub(@PathParam("path") String path); } public static interface Sub { @GET @Produces("text/plain") public String get(); } @Path("/path") public static class RootImpl implements Root { @Override public SubImpl getSub(String path) { return new SubImpl(path); } } public static class SubImpl implements Sub { private final String path; public SubImpl(String path) { this.path = path; } public String get() { return "Boo! - " + path; } }
The issue is that the covariant return methods cause the compiler to generate synthetic methods that are both discovered with introspection and appear to the ResourceMethodRegistry be two separate methods with the same @Path annotations. This is only explicitly checked in the case where the @Path is parameterized - hence the complexity of the case to reproduce.
The fix is to skip synthetic methods in ResourceMethodRegistry.addResourceFactory()