Repository: cxf
Updated Branches:
  refs/heads/master 233faaeb0 -> cc3565f3e


[CXF-7478] Response stream can not be auto-closed if it is read implicitly


Project: http://git-wip-us.apache.org/repos/asf/cxf/repo
Commit: http://git-wip-us.apache.org/repos/asf/cxf/commit/9ef150dd
Tree: http://git-wip-us.apache.org/repos/asf/cxf/tree/9ef150dd
Diff: http://git-wip-us.apache.org/repos/asf/cxf/diff/9ef150dd

Branch: refs/heads/master
Commit: 9ef150dd971b8f8752e3fd3c7eec2fe5de41f160
Parents: 265a4c0
Author: Sergey Beryozkin <[email protected]>
Authored: Thu Aug 17 09:49:52 2017 +0100
Committer: Sergey Beryozkin <[email protected]>
Committed: Thu Aug 17 09:49:52 2017 +0100

----------------------------------------------------------------------
 .../src/main/java/org/apache/cxf/jaxrs/utils/JAXRSUtils.java | 8 +++++++-
 .../src/main/java/org/apache/cxf/jaxrs/client/WebClient.java | 2 +-
 .../apache/cxf/systest/jaxrs/JAXRSClientServerBookTest.java  | 2 +-
 3 files changed, 9 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cxf/blob/9ef150dd/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/utils/JAXRSUtils.java
----------------------------------------------------------------------
diff --git 
a/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/utils/JAXRSUtils.java 
b/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/utils/JAXRSUtils.java
index 87217bf..c803fab 100644
--- a/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/utils/JAXRSUtils.java
+++ b/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/utils/JAXRSUtils.java
@@ -1725,8 +1725,14 @@ public final class JAXRSUtils {
     }
 
     public static ResponseBuilder fromResponse(Response response) {
+        return fromResponse(response, true);
+    }
+    
+    public static ResponseBuilder fromResponse(Response response, boolean 
copyEntity) {
         ResponseBuilder rb = toResponseBuilder(response.getStatus());
-        rb.entity(response.getEntity());
+        if (copyEntity) {
+            rb.entity(response.getEntity());
+        }
         for (Map.Entry<String, List<Object>> entry : 
response.getMetadata().entrySet()) {
             List<Object> values = entry.getValue();
             for (Object value : values) {

http://git-wip-us.apache.org/repos/asf/cxf/blob/9ef150dd/rt/rs/client/src/main/java/org/apache/cxf/jaxrs/client/WebClient.java
----------------------------------------------------------------------
diff --git 
a/rt/rs/client/src/main/java/org/apache/cxf/jaxrs/client/WebClient.java 
b/rt/rs/client/src/main/java/org/apache/cxf/jaxrs/client/WebClient.java
index 848b411..89f5805 100644
--- a/rt/rs/client/src/main/java/org/apache/cxf/jaxrs/client/WebClient.java
+++ b/rt/rs/client/src/main/java/org/apache/cxf/jaxrs/client/WebClient.java
@@ -1144,7 +1144,7 @@ public class WebClient extends AbstractClient {
                     entity = currentResponse.getEntity();
                 }
             }
-            rb = JAXRSUtils.fromResponse(currentResponse);
+            rb = JAXRSUtils.fromResponse(currentResponse, false);
 
             rb.entity(entity instanceof Response
                       ? ((Response)entity).getEntity() : entity);

http://git-wip-us.apache.org/repos/asf/cxf/blob/9ef150dd/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSClientServerBookTest.java
----------------------------------------------------------------------
diff --git 
a/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSClientServerBookTest.java
 
b/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSClientServerBookTest.java
index d551e81..577f0e2 100644
--- 
a/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSClientServerBookTest.java
+++ 
b/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSClientServerBookTest.java
@@ -118,7 +118,7 @@ public class JAXRSClientServerBookTest extends 
AbstractBusClientServerTestBase {
         // and this property is not already set. The async conduit is loaded 
in the tests module
         // but we do want to test HTTPUrlConnection reflection hence we set 
this property to false
         
WebClient.getConfig(wc).getRequestContext().put("use.async.http.conduit", 
false);
-
+        
WebClient.getConfig(wc).getRequestContext().put("response.stream.auto.close", 
true);
         return wc.invoke("RETRIEVE", new Book("Retrieve", 123L), Book.class);
     }
 

Reply via email to