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

AsyncResponse resume omits GenericEntity type


    • Icon: Bug Bug
    • Resolution: Done
    • Icon: Major Major
    • 4.0.0.CR3, 3.7.0.Final
    • 3.6.3.Final, 4.0.0.CR2
    • jaxrs
    • None

      Resuming AsyncResponse with GenericEntity respects the given MediaType but not generic type. This can be worked around by supplying a response object but the problem may be rather tricky to spot.

      As a fix I propose that when GenericEntity is given then methods generic return type isn't used. This approach is taken already in resolveContentTypeByAccept of ResourceMethodInvoker.

      Unable to find source-code formatter for language: diff. Available languages are: actionscript, ada, applescript, bash, c, c#, c++, cpp, css, erlang, go, groovy, haskell, html, java, javascript, js, json, lua, none, nyan, objc, perl, php, python, r, rainbow, ruby, scala, sh, sql, swift, visualbasic, xml, yaml
      diff --git a/resteasy-jaxrs/src/main/java/org/jboss/resteasy/core/AbstractAsynchronousResponse.java b/resteasy-jaxrs/src/main/java/org/jboss/resteasy/core/AbstractAsynchronousResponse.java
      old mode 100755
      new mode 100644
      index b65a354..7cea751
      --- a/resteasy-jaxrs/src/main/java/org/jboss/resteasy/core/AbstractAsynchronousResponse.java
      +++ b/resteasy-jaxrs/src/main/java/org/jboss/resteasy/core/AbstractAsynchronousResponse.java
      @@ -10,6 +10,7 @@
       import javax.ws.rs.container.CompletionCallback;
       import javax.ws.rs.container.ContainerResponseFilter;
       import javax.ws.rs.container.TimeoutHandler;
      +import javax.ws.rs.core.GenericEntity;
       import javax.ws.rs.core.MediaType;
       import javax.ws.rs.core.Response;
       import javax.ws.rs.ext.WriterInterceptor;
      @@ -185,7 +186,10 @@
                if (method == null) throw new IllegalStateException(Messages.MESSAGES.unknownMediaTypeResponseEntity());
                MediaType type = method.resolveContentType(request, entity);
                BuiltResponse jaxrsResponse = (BuiltResponse)Response.ok(entity, type).build();
      -         jaxrsResponse.setGenericType(method.getGenericReturnType());
      +         if (!(entity instanceof GenericEntity))
      +         {
      +             jaxrsResponse.setGenericType(method.getGenericReturnType());
      +         }
                response = jaxrsResponse;

            rsigal@redhat.com Ronald Sigal
            tuomas_kiviaho Tuomas Kiviaho (Inactive)
            0 Vote for this issue
            3 Start watching this issue