cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From serg...@apache.org
Subject cxf git commit: [CXF-7478] Response stream can not be auto-closed if it is read implicitly
Date Thu, 17 Aug 2017 09:19:16 GMT
Repository: cxf
Updated Branches:
  refs/heads/3.1.x-fixes 1e1996785 -> 0d523a2dc


[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/0d523a2d
Tree: http://git-wip-us.apache.org/repos/asf/cxf/tree/0d523a2d
Diff: http://git-wip-us.apache.org/repos/asf/cxf/diff/0d523a2d

Branch: refs/heads/3.1.x-fixes
Commit: 0d523a2dcb977a4a026627df759235628f1689ff
Parents: 1e19967
Author: Sergey Beryozkin <sberyozkin@gmail.com>
Authored: Thu Aug 17 09:49:52 2017 +0100
Committer: Sergey Beryozkin <sberyozkin@gmail.com>
Committed: Thu Aug 17 10:18:58 2017 +0100

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


http://git-wip-us.apache.org/repos/asf/cxf/blob/0d523a2d/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 a2df8e6..7fdb82c 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
@@ -1730,8 +1730,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/0d523a2d/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 efe03bf..4f8d1aa 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
@@ -1132,9 +1132,9 @@ public class WebClient extends AbstractClient {
                     entity = currentResponse.getEntity();
                 }
             }
-            rb = JAXRSUtils.fromResponse(currentResponse);
-            
-            rb.entity(entity instanceof Response 
+            rb = JAXRSUtils.fromResponse(currentResponse, false);
+
+            rb.entity(entity instanceof Response
                       ? ((Response)entity).getEntity() : entity);
             
             Response r = rb.build();

http://git-wip-us.apache.org/repos/asf/cxf/blob/0d523a2d/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 0cca403..d505e09 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);
     }
     


Mime
View raw message