Repository: cxf Updated Branches: refs/heads/3.0.x-fixes 3533b2858 -> 158121633
[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/15812163 Tree: http://git-wip-us.apache.org/repos/asf/cxf/tree/15812163 Diff: http://git-wip-us.apache.org/repos/asf/cxf/diff/15812163 Branch: refs/heads/3.0.x-fixes Commit: 1581216339423241d7b64b2c8f51b2a0e0fd2094 Parents: 3533b28 Author: Sergey Beryozkin <sberyoz...@gmail.com> Authored: Thu Oct 13 13:44:14 2016 +0100 Committer: Sergey Beryozkin <sberyoz...@gmail.com> Committed: Thu Oct 13 13:45:39 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/15812163/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 6bb597a..e6698c6 100644 --- a/core/src/main/java/org/apache/cxf/io/CachedOutputStream.java +++ b/core/src/main/java/org/apache/cxf/io/CachedOutputStream.java @@ -211,8 +211,9 @@ public class CachedOutputStream extends OutputStream { } doClose(); currentStream.close(); - maybeDeleteTempFile(currentStream); - postClose(); + if (!maybeDeleteTempFile(currentStream)) { + postClose(); + } } public boolean equals(Object obj) { @@ -542,7 +543,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) { @@ -552,11 +554,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 {