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

JAX-RS Annotations on overridden resource methods with generic type parameters are not used

    Details

    • Type: Bug
    • Status: Closed (View Workflow)
    • Priority: Major
    • Resolution: Done
    • Affects Version/s: 3.0.24.Final, 3.1.4.Final
    • Fix Version/s: 4.0.0.Beta1
    • Component/s: jaxrs
    • Labels:
      None
    • Steps to Reproduce:
      Hide
      1. create an abstract resource class with generic type parameter and a resource method with the generic type parameter as method parameter and JAXR-RS annotations
      2. extend the abstract resource class, fill the generic type parameter with a specific class and override the resource method. (Do not annotate the resource method with any JAX-RS annotations)
      Show
      create an abstract resource class with generic type parameter and a resource method with the generic type parameter as method parameter and JAXR-RS annotations extend the abstract resource class, fill the generic type parameter with a specific class and override the resource method. (Do not annotate the resource method with any JAX-RS annotations)

      Description

      If a superclass with generic type parameters of a root resource contains resource methods with generic type parameters and JAX-RS Annotations, the JAX-RS annotations are not used.
      This case should be within the scope of the JAX-RS Annotation inheritance specification.

      The issue lies within the discovery process of overridden methods in superclasses / interfaces which does not resolve generic type arguments to actual types at runtime.
      The current discovery process for overridden methods iterates over all superclasses and interfaces and looks for methods with the same function signature. But because of type erasure the overridden method presents the generic parameters as Object which does not match the specific type of the implemented method at runtime.

      As a solution generic type parameters in method signatures have to be resolved in the course of the annotation inheritance discovery process.

      https://github.com/resteasy/Resteasy/blob/3.0/resteasy-jaxrs/src/main/java/org/jboss/resteasy/core/ResourceMethodRegistry.java#L342
      https://github.com/resteasy/Resteasy/blob/3.0/resteasy-jaxrs/src/main/java/org/jboss/resteasy/spi/metadata/ResourceBuilder.java#L794

        Gliffy Diagrams

          Attachments

            Activity

              People

              • Assignee:
                asoldano Alessio Soldano
                Reporter:
                frederik.boster Frederik Boster
              • Votes:
                0 Vote for this issue
                Watchers:
                1 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: