You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cxf.apache.org by dk...@apache.org on 2010/01/29 20:15:53 UTC
svn commit: r904597 -
/cxf/trunk/api/src/main/java/org/apache/cxf/io/DelegatingInputStream.java
Author: dkulp
Date: Fri Jan 29 19:15:51 2010
New Revision: 904597
URL: http://svn.apache.org/viewvc?rev=904597&view=rev
Log:
Fix an issue where one-way requests may mess up the input stream for
other requests
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=904597&r1=904596&r2=904597&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 Fri Jan 29 19:15:51 2010
@@ -19,6 +19,7 @@
package org.apache.cxf.io;
+import java.io.ByteArrayInputStream;
import java.io.FilterInputStream;
import java.io.IOException;
import java.io.InputStream;
@@ -26,12 +27,10 @@
import org.apache.cxf.helpers.IOUtils;
public class DelegatingInputStream extends FilterInputStream {
- private InputStream origIn;
- private boolean cached;
+ protected boolean cached;
public DelegatingInputStream(InputStream is) {
super(is);
- origIn = is;
}
@@ -42,14 +41,6 @@
return in;
}
-
- public void close() throws IOException {
- super.close();
- if (in != origIn) {
- origIn.close();
- }
- }
-
/**
* Read the entire original input stream and cache it. Useful
* if switching threads or doing something where the original
@@ -59,11 +50,15 @@
if (!cached) {
CachedOutputStream cache = new CachedOutputStream();
try {
+ InputStream origIn = in;
IOUtils.copy(in, cache);
if (cache.size() > 0) {
in = cache.getInputStream();
+ } else {
+ in = new ByteArrayInputStream(new byte[0]);
}
cache.close();
+ origIn.close();
} catch (IOException e) {
//ignore
}