You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cxf.apache.org by se...@apache.org on 2016/10/13 12:44:32 UTC
cxf git commit: [CXF-6981] Avoid double close in
CacheAndWriteOutputStream, patch from Andy McCright applied, This closes #179
Repository: cxf
Updated Branches:
refs/heads/master eb1049f81 -> e45cc2543
[CXF-6981] Avoid double close in CacheAndWriteOutputStream, patch from Andy McCright applied, This closes #179
Project: http://git-wip-us.apache.org/repos/asf/cxf/repo
Commit: http://git-wip-us.apache.org/repos/asf/cxf/commit/e45cc254
Tree: http://git-wip-us.apache.org/repos/asf/cxf/tree/e45cc254
Diff: http://git-wip-us.apache.org/repos/asf/cxf/diff/e45cc254
Branch: refs/heads/master
Commit: e45cc2543940de2d8587a1c86cf7db28b8dd7203
Parents: eb1049f
Author: Sergey Beryozkin <sb...@gmail.com>
Authored: Thu Oct 13 13:44:14 2016 +0100
Committer: Sergey Beryozkin <sb...@gmail.com>
Committed: Thu Oct 13 13:44:14 2016 +0100
----------------------------------------------------------------------
.../main/java/org/apache/cxf/io/CachedOutputStream.java | 10 +++++++---
1 file changed, 7 insertions(+), 3 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cxf/blob/e45cc254/core/src/main/java/org/apache/cxf/io/CachedOutputStream.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/cxf/io/CachedOutputStream.java b/core/src/main/java/org/apache/cxf/io/CachedOutputStream.java
index eeced83..9c8175f 100644
--- a/core/src/main/java/org/apache/cxf/io/CachedOutputStream.java
+++ b/core/src/main/java/org/apache/cxf/io/CachedOutputStream.java
@@ -212,8 +212,9 @@ public class CachedOutputStream extends OutputStream {
}
doClose();
currentStream.close();
- maybeDeleteTempFile(currentStream);
- postClose();
+ if (!maybeDeleteTempFile(currentStream)) {
+ postClose();
+ }
}
public boolean equals(Object obj) {
@@ -527,7 +528,8 @@ public class CachedOutputStream extends OutputStream {
FileUtils.delete(file);
}
}
- private void maybeDeleteTempFile(Object stream) {
+ private boolean maybeDeleteTempFile(Object stream) {
+ boolean postClosedInvoked = false;
streamList.remove(stream);
if (!inmem && tempFile != null && streamList.isEmpty() && allowDeleteOfFile) {
if (currentStream != null) {
@@ -537,11 +539,13 @@ public class CachedOutputStream extends OutputStream {
} catch (Exception e) {
//ignore
}
+ postClosedInvoked = true;
}
deleteTempFile();
currentStream = new LoadingByteArrayOutputStream(1024);
inmem = true;
}
+ return postClosedInvoked;
}
public void setOutputDir(File outputDir) throws IOException {