Author: dkulp Date: Tue Oct 2 20:09:49 2012 New Revision: 1393149 URL: http://svn.apache.org/viewvc?rev=1393149&view=rev Log: Merged revisions 1393139 via git cherry-pick from https://svn.apache.org/repos/asf/cxf/branches/2.5.x-fixes
........ r1393139 | dkulp | 2012-10-02 15:44:58 -0400 (Tue, 02 Oct 2012) | 18 lines Merged revisions 1393109 via git cherry-pick from https://svn.apache.org/repos/asf/cxf/branches/2.6.x-fixes ........ r1393109 | dkulp | 2012-10-02 15:09:33 -0400 (Tue, 02 Oct 2012) | 10 lines Merged revisions 1393095 via git cherry-pick from https://svn.apache.org/repos/asf/cxf/trunk ........ r1393095 | dkulp | 2012-10-02 14:50:19 -0400 (Tue, 02 Oct 2012) | 2 lines [CXF-4533] Use a Reader to read from the input stream as chars instead of trying to handle it ourselves. ........ ........ ........ Modified: cxf/branches/2.4.x-fixes/api/src/main/java/org/apache/cxf/io/CachedOutputStream.java Modified: cxf/branches/2.4.x-fixes/api/src/main/java/org/apache/cxf/io/CachedOutputStream.java URL: http://svn.apache.org/viewvc/cxf/branches/2.4.x-fixes/api/src/main/java/org/apache/cxf/io/CachedOutputStream.java?rev=1393149&r1=1393148&r2=1393149&view=diff ============================================================================== --- cxf/branches/2.4.x-fixes/api/src/main/java/org/apache/cxf/io/CachedOutputStream.java (original) +++ cxf/branches/2.4.x-fixes/api/src/main/java/org/apache/cxf/io/CachedOutputStream.java Tue Oct 2 20:09:49 2012 @@ -28,9 +28,11 @@ import java.io.FileNotFoundException; import java.io.FileOutputStream; import java.io.IOException; import java.io.InputStream; +import java.io.InputStreamReader; import java.io.OutputStream; import java.io.PipedInputStream; import java.io.PipedOutputStream; +import java.io.Reader; import java.util.ArrayList; import java.util.Collections; import java.util.List; @@ -306,21 +308,23 @@ public class CachedOutputStream extends } else { // read the file FileInputStream fin = new FileInputStream(tempFile); - byte bytes[] = new byte[1024]; - int x = fin.read(bytes); + Reader reader = new InputStreamReader(fin, charsetName); + char bytes[] = new char[1024]; + long x = reader.read(bytes); while (x != -1) { if ((count + x) > limit) { x = limit - count; } - out.append(IOUtils.newStringFromBytes(bytes, charsetName, 0, x)); + out.append(bytes, 0, (int)x); count += x; if (count >= limit) { x = -1; } else { - x = fin.read(bytes); + x = reader.read(bytes); } } + reader.close(); fin.close(); } } @@ -341,12 +345,14 @@ public class CachedOutputStream extends } else { // read the file FileInputStream fin = new FileInputStream(tempFile); - byte bytes[] = new byte[1024]; - int x = fin.read(bytes); + Reader reader = new InputStreamReader(fin, charsetName); + char bytes[] = new char[1024]; + int x = reader.read(bytes); while (x != -1) { - out.append(IOUtils.newStringFromBytes(bytes, charsetName, 0, x)); - x = fin.read(bytes); + out.append(bytes, 0, x); + x = reader.read(bytes); } + reader.close(); fin.close(); } }
