cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dk...@apache.org
Subject svn commit: r900900 - /cxf/trunk/api/src/main/java/org/apache/cxf/io/DelegatingInputStream.java
Date Tue, 19 Jan 2010 18:45:53 GMT
Author: dkulp
Date: Tue Jan 19 18:45:53 2010
New Revision: 900900

URL: http://svn.apache.org/viewvc?rev=900900&view=rev
Log:
Slight Optimization

Modified:
    cxf/trunk/api/src/main/java/org/apache/cxf/io/DelegatingInputStream.java

Modified: cxf/trunk/api/src/main/java/org/apache/cxf/io/DelegatingInputStream.java
URL: http://svn.apache.org/viewvc/cxf/trunk/api/src/main/java/org/apache/cxf/io/DelegatingInputStream.java?rev=900900&r1=900899&r2=900900&view=diff
==============================================================================
--- cxf/trunk/api/src/main/java/org/apache/cxf/io/DelegatingInputStream.java (original)
+++ cxf/trunk/api/src/main/java/org/apache/cxf/io/DelegatingInputStream.java Tue Jan 19 18:45:53
2010
@@ -27,6 +27,7 @@
 
 public class DelegatingInputStream extends FilterInputStream {
     private InputStream origIn;
+    private boolean cached;
     
     public DelegatingInputStream(InputStream is) {
         super(is);
@@ -55,15 +56,18 @@
      * stream may not be valid by the time the next read() occurs
      */
     public void cacheInput() {
-        if (in != origIn) {
+        if (!cached) {
             CachedOutputStream cache = new CachedOutputStream();
             try {
-                IOUtils.copy(in, cache); 
-                in = cache.getInputStream();
+                IOUtils.copy(in, cache);
+                if (cache.size() > 0) {
+                    in = cache.getInputStream();
+                }
                 cache.close();
             } catch (IOException e) {
                 //ignore
             }
+            cached = true;
         }
     }
     



Mime
View raw message