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:33:33 GMT
Repository: cxf
Updated Branches:
  refs/heads/3.0.x-fixes d3e7cb90a -> 4b471d869


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

Branch: refs/heads/3.0.x-fixes
Commit: 4b471d86974a347858496e60afebfd512d53fe7d
Parents: d3e7cb9
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:32:44 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/4b471d86/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