andymc12 commented on a change in pull request #851:
URL: https://github.com/apache/cxf/pull/851#discussion_r711149701



##########
File path: 
rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/impl/ResponseImpl.java
##########
@@ -418,7 +418,7 @@ private Link makeAbsoluteLink(Link link) {
 
     public <T> T doReadEntity(Class<T> cls, Type t, Annotation[] anns)
         throws ProcessingException, IllegalStateException {
-        return doReadEntity(cls, t, anns, false);
+        return doReadEntity(cls, t, anns, 
!InputStream.class.isAssignableFrom(cls));

Review comment:
       In the case of proxy clients, I think CXF should be closing the 
`Response`.  I think we may already do that in some cases where the `Response` 
object is not visible to the user.  Maybe we should modify the 
`WebClient.castResponse` method to also conditionally close the response - 
something like this:
   ```
   @SuppressWarnings("unchecked")
   private <T> T castResponse(Response r, Class<T> responseClass) {
       if (responseClass == Response.class)
           return r;
       try (Response r2 = r) {
           return (T) r.getEntity();
       }
   }
   ```
   
   This might need some testing, but I cannot think of a case where we would 
need to keep the `Response` open if the user cannot access it. An alternative 
would be to close the `Response` in the various `invoke` methods, but that 
might be more code than necessary.  Then maybe something similar in 
`ClientProxyImpl.handleResponse`.  Wdyt?




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


Reply via email to