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

CLONE - Generic Return Types don't work with Java Proxy

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Done
    • Icon: Critical Critical
    • 3.0-beta-5
    • None
    • jaxrs
    • None

      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.

        1. MultipleInterfaceResourceLocatorTest.java
          2 kB
          Ronald Sigal
        2. ProxyWithGenericReturnType.java
          3 kB
          Ronald Sigal
        3. ProxyWithGenericReturnType.java
          5 kB
          Ronald Sigal
        4. ProxyWithGenericReturnTypeJacksonTest.java
          5 kB
          Ronald Sigal
        5. ProxyWithGenericReturnTypeTest.java
          5 kB
          Ronald Sigal

              rsigal@redhat.com Ronald Sigal
              NvtMorch Holger Morch (Inactive)
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

                Created:
                Updated:
                Resolved: