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

Generic Return Types don't work with Java Proxy

    Details

      Description

      This issue seems to be the same as RESTEASY-685 but for return type. RESTEASY-685 was about parameter.

      This worked with 2.2.2.GA. It is broken since 2.3.0.GA.

      All of our resources are are created with Spring. We are using AOP in Spring for security and other things. In this case we have a first level resource which constructs a sub resource using Spring. Due to the AOP stuff the returned object is a proxy. Additionally the jax-rs annotations are in an interface.

      We are using Jackson Json Mapper to generate the output. Jackson is configured to us tying (write a type property to output). If the returned object is generic e.g. a List<MyObject> Jackson need generic type information to do this.
      With 2.2.2.GA a ParameterizedTypeImpl was passed to JacksonJsonProvider.writeTo method. With 2.3.4.Final it is a class object without generic type information.

      I had a look into the sources and it looks like the cause is the same as in RESTEASY-685:
      org.jboss.resteasy.core.ResourceLocator.invokeOnTargetObject(HttpRequest, HttpResponse, Object):
      2.2.2.GA - line 133: registry.addResourceFactory(null, null, subResourceClass);
      2.3.2.Final - line 134: registry.addResourceFactory(null, null, target.getClass());//subResourceClass);
      So with 2.2.2.GA the Interface was passed to ResourceMethodRegistry and this passes methods with generic type information to ResourceMethod.
      With 2.3.2.Final the Proxy class itself is used. Since this doesn't contain the generic type information the wrong type is passed to Jackson.

      Can you please add a fix like the one from RESTEASY-685 for return types.

        Gliffy Diagrams

          Attachments

            Issue Links

              Activity

                People

                • Assignee:
                  ron_sigal Ronald Sigal
                  Reporter:
                  NvtMorch Holger Morch
                • Votes:
                  0 Vote for this issue
                  Watchers:
                  4 Start watching this issue

                  Dates

                  • Created:
                    Updated:
                    Resolved: