You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@chemistry.apache.org by fm...@apache.org on 2012/05/09 19:48:45 UTC
svn commit: r1336315 -
/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-bindings/src/main/java/org/apache/chemistry/opencmis/server/shared/ThresholdOutputStream.java
Author: fmui
Date: Wed May 9 17:48:45 2012
New Revision: 1336315
URL: http://svn.apache.org/viewvc?rev=1336315&view=rev
Log:
Server: more robust stream handling
Modified:
chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-bindings/src/main/java/org/apache/chemistry/opencmis/server/shared/ThresholdOutputStream.java
Modified: chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-bindings/src/main/java/org/apache/chemistry/opencmis/server/shared/ThresholdOutputStream.java
URL: http://svn.apache.org/viewvc/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-bindings/src/main/java/org/apache/chemistry/opencmis/server/shared/ThresholdOutputStream.java?rev=1336315&r1=1336314&r2=1336315&view=diff
==============================================================================
--- chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-bindings/src/main/java/org/apache/chemistry/opencmis/server/shared/ThresholdOutputStream.java (original)
+++ chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-bindings/src/main/java/org/apache/chemistry/opencmis/server/shared/ThresholdOutputStream.java Wed May 9 17:48:45 2012
@@ -332,6 +332,7 @@ public class ThresholdOutputStream exten
private class InternalTempFileInputStream extends FilterInputStream implements ThresholdInputStream {
private boolean isDeleted = false;
+ private boolean isClosed = false;
public InternalTempFileInputStream() throws FileNotFoundException {
super(new BufferedInputStream(new FileInputStream(tempFile), memoryThreshold));
@@ -356,10 +357,18 @@ public class ThresholdOutputStream exten
@Override
public int read() throws IOException {
+ if (isClosed) {
+ return -1;
+ }
+
int b = super.read();
if (b == -1 && !isDeleted) {
- super.close();
+ try {
+ super.close();
+ isClosed = true;
+ } catch (Exception e) {
+ }
isDeleted = tempFile.delete();
}
@@ -373,10 +382,18 @@ public class ThresholdOutputStream exten
@Override
public int read(byte[] b, int off, int len) throws IOException {
+ if (isClosed) {
+ return -1;
+ }
+
int n = super.read(b, off, len);
if (n == -1 && !isDeleted) {
- super.close();
+ try {
+ super.close();
+ isClosed = true;
+ } catch (Exception e) {
+ }
isDeleted = tempFile.delete();
}
@@ -385,8 +402,15 @@ public class ThresholdOutputStream exten
@Override
public void close() throws IOException {
+ if (!isClosed) {
+ try {
+ super.close();
+ isClosed = true;
+ } catch (Exception e) {
+ }
+ }
+
if (!isDeleted) {
- super.close();
isDeleted = tempFile.delete();
}
}