cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From serg...@apache.org
Subject [2/2] git commit: Updating Binary provider to keep the response input stream opened if requested
Date Thu, 24 Jul 2014 14:01:11 GMT
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/a1370a62
Tree: http://git-wip-us.apache.org/repos/asf/cxf/tree/a1370a62
Diff: http://git-wip-us.apache.org/repos/asf/cxf/diff/a1370a62

Branch: refs/heads/3.0.x-fixes
Commit: a1370a6201d0dfe9e449a0e159abc49831f9b7bd
Parents: d607ef3
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 17:00:45 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/a1370a62/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