Uploaded image for project: 'RESTEasy'
  1. RESTEasy
  2. RESTEASY-612

covariant return types on subresource locators causing exceptions

    XMLWordPrintable

Details

    • Bug
    • Resolution: Done
    • Major
    • None
    • 2.3-beta-1
    • jaxrs
    • 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()

      Attachments

        Activity

          People

            patriot1burke@gmail.com Bill Burke (Inactive)
            yarrumretep_jira Peter Murray (Inactive)
            Votes:
            1 Vote for this issue
            Watchers:
            5 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: