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

Failure to match subresource target for one HTTP verb but not another

    XMLWordPrintable

Details

    • Bug
    • Resolution: Done
    • Major
    • 2.0.1.GA
    • 2.0.GA
    • jaxrs
    • None

    Description

      If the resource class hierarchy looks like the one described below, then a GET is properly dispatched but a POST on the same URI fails with a 404.

      AnnotationFreeSubResource -implements> SubInterface --extends-> RootInterface
      \
      +-extends> AbstractAnnotationFreeResouce --implements-> RootInterface

      where the following annotations are present:

      RootInterface - @GET and @Path on separate methods
      SubInterface - @POST on a single method
      AbstractAnnotationFreeResouce - no direct annotations, implements @GET method inherited from RootInterface
      AnnotationFreeResouce - no direct annotations, implements @Path method from RootInterface and @POST method from SubInterface

      The underlying issue occurs when org.jboss.resteasy.util.GetRestful.getResourceClass() walks the class/interface hierarchy searching for JAX-RS annotations. After ascending from AnnotationFreeSubResource to AbstractAnnotationFreeResouce, GetRestful.hasJAXRSAnnotations() sees the abstract @Path-annotated method inherited from RootInterface and terminates the search at that point, even though AbstractAnnotationFreeResouce is not itself directly annotated.

      The problem is that GetRestful.hasJAXRSAnnotations() uses Class.getMethods() and hence see un-implemented methods from implemented interfaces as abstract methods on the current class. Instead it should use Class.getDeclaredMethods() so as to only to consider methods declared directly on the current class/interface.

      Attachments

        Activity

          People

            patriot1burke@gmail.com Bill Burke (Inactive)
            eglynn_jira Eoghan Glynn (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: