cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From a.@apache.org
Subject cxf git commit: minor fix to previos JAXRS String writer change
Date Thu, 05 Mar 2015 17:31:40 GMT
Repository: cxf
Updated Branches:
  refs/heads/master 3bf34699f -> e8e27511f


minor fix to previos JAXRS String writer change


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

Branch: refs/heads/master
Commit: e8e27511f350b48088bf63527af7b45124ea1692
Parents: 3bf3469
Author: Akitoshi Yoshida <ay@apache.org>
Authored: Thu Mar 5 18:31:06 2015 +0100
Committer: Akitoshi Yoshida <ay@apache.org>
Committed: Thu Mar 5 18:31:12 2015 +0100

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


http://git-wip-us.apache.org/repos/asf/cxf/blob/e8e27511/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/PrimitiveTextProvider.java
----------------------------------------------------------------------
diff --git a/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/PrimitiveTextProvider.java
b/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/PrimitiveTextProvider.java
index 392c36d..93a6135 100644
--- a/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/PrimitiveTextProvider.java
+++ b/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/PrimitiveTextProvider.java
@@ -18,7 +18,6 @@
  */
 package org.apache.cxf.jaxrs.provider;
 
-import java.io.ByteArrayInputStream;
 import java.io.IOException;
 import java.io.InputStream;
 import java.io.OutputStream;
@@ -77,9 +76,18 @@ public class PrimitiveTextProvider<T>
                         MediaType mt, MultivaluedMap<String, Object> headers,
                         OutputStream os) throws IOException {
         String encoding = HttpUtils.getSetEncoding(mt, headers, "UTF-8");
+        //REVISIT try to avoid instantiating the whole byte array
         byte[] bytes = obj.toString().getBytes(encoding);
         if (bytes.length > bufferSize) {
-            IOUtils.copy(new ByteArrayInputStream(bytes), os, bufferSize);
+            int pos = 0;
+            while (pos < bytes.length) {
+                int bl = bytes.length - pos;
+                if (bl > bufferSize) {
+                    bl = bufferSize;
+                }
+                os.write(bytes, pos, bl);
+                pos += bl;
+            }
         } else {
             os.write(bytes);
         }


Mime
View raw message