Return-Path: X-Original-To: apmail-cxf-commits-archive@www.apache.org Delivered-To: apmail-cxf-commits-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 4A8FA17EDB for ; Thu, 5 Mar 2015 17:33:33 +0000 (UTC) Received: (qmail 71642 invoked by uid 500); 5 Mar 2015 17:33:33 -0000 Delivered-To: apmail-cxf-commits-archive@cxf.apache.org Received: (qmail 71587 invoked by uid 500); 5 Mar 2015 17:33:33 -0000 Mailing-List: contact commits-help@cxf.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@cxf.apache.org Delivered-To: mailing list commits@cxf.apache.org Received: (qmail 71578 invoked by uid 99); 5 Mar 2015 17:33:33 -0000 Received: from git1-us-west.apache.org (HELO git1-us-west.apache.org) (140.211.11.23) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 05 Mar 2015 17:33:33 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id 04982E03B0; Thu, 5 Mar 2015 17:33:33 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: ay@apache.org To: commits@cxf.apache.org Message-Id: <0b4804a00d0349a7804810dce04d9c8b@git.apache.org> X-Mailer: ASF-Git Admin Mailer Subject: cxf git commit: minor fix to previos JAXRS String writer change Date: Thu, 5 Mar 2015 17:33:33 +0000 (UTC) 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 Authored: Thu Mar 5 18:31:06 2015 +0100 Committer: Akitoshi Yoshida 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 MediaType mt, MultivaluedMap 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); }