cxf git commit: [CXF-6981] Avoid double close in CacheAndWriteOutputStream, patch from Andy McCright applied, This closes #179
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 BeryozkinAuthored: Thu Oct 13 13:44:14 2016 +0100 Committer: Sergey Beryozkin 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 {
cxf git commit: [CXF-6981] Avoid double close in CacheAndWriteOutputStream, patch from Andy McCright applied, This closes #179
Repository: cxf Updated Branches: refs/heads/3.1.x-fixes b6191970a -> c99d22610 [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/c99d2261 Tree: http://git-wip-us.apache.org/repos/asf/cxf/tree/c99d2261 Diff: http://git-wip-us.apache.org/repos/asf/cxf/diff/c99d2261 Branch: refs/heads/3.1.x-fixes Commit: c99d226104c260943b1d5306889f6fb6b5bcc623 Parents: b619197 Author: Sergey BeryozkinAuthored: Thu Oct 13 13:44:14 2016 +0100 Committer: Sergey Beryozkin Committed: Thu Oct 13 13:45:01 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/c99d2261/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 {
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 BeryozkinAuthored: Thu Oct 13 13:44:14 2016 +0100 Committer: Sergey Beryozkin 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 {