cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From serg...@apache.org
Subject [1/2] git commit: Updating Binary provider to keep the response input stream opened if requested
Date Thu, 24 Jul 2014 13:57:24 GMT
Repository: cxf
Updated Branches:
  refs/heads/master 67432aef1 -> eac181502


Updating Binary provider to keep the response input stream opened if requested


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

Branch: refs/heads/master
Commit: c36df2aab074a1c91af110cb2a91a0b1c9169773
Parents: 08d98fb
Author: Sergey Beryozkin <sberyozkin@talend.com>
Authored: Thu Jul 24 16:56:23 2014 +0300
Committer: Sergey Beryozkin <sberyozkin@talend.com>
Committed: Thu Jul 24 16:56:23 2014 +0300

----------------------------------------------------------------------
 .../apache/cxf/jaxrs/provider/BinaryDataProvider.java   | 12 ++++++++++--
 1 file changed, 10 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cxf/blob/c36df2aa/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/BinaryDataProvider.java
----------------------------------------------------------------------
diff --git a/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/BinaryDataProvider.java
b/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/BinaryDataProvider.java
index 704ec8e..48bf561 100644
--- a/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/BinaryDataProvider.java
+++ b/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/BinaryDataProvider.java
@@ -59,7 +59,7 @@ public class BinaryDataProvider<T> extends AbstractConfigurableProvider
     
     private static final int BUFFER_SIZE = 4096;
     private boolean reportByteArraySize;
-    
+    private boolean closeResponseInputStream;
     public boolean isReadable(Class<?> type, Type genericType, Annotation[] annotations,
MediaType mt) {
         return byte[].class.isAssignableFrom(type)
                || InputStream.class.isAssignableFrom(type)
@@ -161,7 +161,11 @@ public class BinaryDataProvider<T> extends AbstractConfigurableProvider
             Message inMessage = PhaseInterceptorChain.getCurrentMessage().getExchange().getInMessage();
             handleRangeRequest(is, os, new HttpHeadersImpl(inMessage), outHeaders);
         } else {
-            IOUtils.copyAndCloseInput(is, os);
+            if (closeResponseInputStream) {
+                IOUtils.copyAndCloseInput(is, os);
+            } else {
+                IOUtils.copy(is, os);
+            }
         }
     }
     
@@ -190,4 +194,8 @@ public class BinaryDataProvider<T> extends AbstractConfigurableProvider
     public void setReportByteArraySize(boolean report) {
         this.reportByteArraySize = report;
     }
+
+    public void setCloseResponseInputStream(boolean closeResponseInputStream) {
+        this.closeResponseInputStream = closeResponseInputStream;
+    }
 }


Mime
View raw message