RESTEasy
  1. RESTEasy
  2. RESTEASY-730

405 when method implemented generically in ancestor

    Details

    • Type: Bug Bug
    • Status: Closed Closed (View Workflow)
    • Priority: Major Major
    • Resolution: Rejected
    • Affects Version/s: 2.3.2.Final
    • Fix Version/s: None
    • Component/s: jaxrs
    • Labels:
      None
    • Similar Issues:
      Show 10 results 

      Description

      This bug is a bit complicated, best explained by example:

      1)
      class Disk extends Device {}

      2)
      class DeviceResource<D extends Device> { //notice: implementation of get() is with generic return type
      public D get(String id)

      { //... implementation, get the device }

      }

      3)
      class DiskResource extends DeviceResource<Disk> implements DiskResourceIfc{}

      4)
      interface DiskResourceIfc

      { @GET @Formatted public Disk get(); }

      When I try to GET a Disk I get 405 - method not allowed. I believe the reason for this is that rest-easy, using reflection, looks for implementation of: "public Disk get()" and doesn't find it, because the implementation is in the generic: "public D get()". The work-around that I found for the problem is overriding the generic method and calling super():

      class DiskResource extends DeviceResource<Disk> implements DiskResourceIfc{
      @Override
      public Disk get()

      { super.get(); }

      }

      Then it works.

      I believe that the behavior should be: if rest-easy doesn't find the exact method (i.e: "public Disk get()", it should search for possible generic signatures (i.e: "public D get()" ,D extends Device)

        Activity

        Hide
        Ron Sigal
        added a comment -

        Hi Ori,

        The problem might be a missing @GET. Although DiskResource implements DiskResourceIfc, DeviceResource does not, so DeviceResource.get() doesn't inherit the @GET annotation from DiskResourceIfc.get(). I've written a test based on your example, and when I add a @GET to DeviceResource.get(), it runs fine. When I leave it off, I get a 404. Note that your second version of DiskResource has a get() which DOES inherit the @GET.

        I've attached an Eclipse project with my test. Could you take a look?

        Thanks,
        Ron

        Show
        Ron Sigal
        added a comment - Hi Ori, The problem might be a missing @GET. Although DiskResource implements DiskResourceIfc, DeviceResource does not, so DeviceResource.get() doesn't inherit the @GET annotation from DiskResourceIfc.get(). I've written a test based on your example, and when I add a @GET to DeviceResource.get(), it runs fine. When I leave it off, I get a 404. Note that your second version of DiskResource has a get() which DOES inherit the @GET. I've attached an Eclipse project with my test. Could you take a look? Thanks, Ron
        Hide
        Ron Sigal
        added a comment -

        Hi Ori,

        I'm going to close this issue. If you have anything to add, you can re-open it.

        -Ron

        Show
        Ron Sigal
        added a comment - Hi Ori, I'm going to close this issue. If you have anything to add, you can re-open it. -Ron

          People

          • Assignee:
            Ron Sigal
            Reporter:
            Ori Liel
          • Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved: