You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by bo...@apache.org on 2016/06/11 15:34:08 UTC
[1/3] commons-compress git commit: Revert "better set that flag
earlier"
Repository: commons-compress
Updated Branches:
refs/heads/master bdc5ad445 -> abc2d2390
Revert "better set that flag earlier"
This reverts commit bdc5ad445101133b7c92f4b2efbad1993913e160.
Project: http://git-wip-us.apache.org/repos/asf/commons-compress/repo
Commit: http://git-wip-us.apache.org/repos/asf/commons-compress/commit/e9d62218
Tree: http://git-wip-us.apache.org/repos/asf/commons-compress/tree/e9d62218
Diff: http://git-wip-us.apache.org/repos/asf/commons-compress/diff/e9d62218
Branch: refs/heads/master
Commit: e9d6221823e2e0d731a11a8a8931db2e83ca6e5c
Parents: bdc5ad4
Author: Stefan Bodewig <bo...@apache.org>
Authored: Sat Jun 11 17:27:14 2016 +0200
Committer: Stefan Bodewig <bo...@apache.org>
Committed: Sat Jun 11 17:27:14 2016 +0200
----------------------------------------------------------------------
.../compress/compressors/bzip2/BZip2CompressorOutputStream.java | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/commons-compress/blob/e9d62218/src/main/java/org/apache/commons/compress/compressors/bzip2/BZip2CompressorOutputStream.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/commons/compress/compressors/bzip2/BZip2CompressorOutputStream.java b/src/main/java/org/apache/commons/compress/compressors/bzip2/BZip2CompressorOutputStream.java
index 8cc6c39..483d844 100644
--- a/src/main/java/org/apache/commons/compress/compressors/bzip2/BZip2CompressorOutputStream.java
+++ b/src/main/java/org/apache/commons/compress/compressors/bzip2/BZip2CompressorOutputStream.java
@@ -479,7 +479,6 @@ public class BZip2CompressorOutputStream extends CompressorOutputStream
public void finish() throws IOException {
if (!closed) {
- closed = true;
try {
if (this.runLength > 0) {
writeRun();
@@ -488,6 +487,7 @@ public class BZip2CompressorOutputStream extends CompressorOutputStream
endBlock();
endCompression();
} finally {
+ closed = true;
this.out = null;
this.data = null;
this.blockSorter = null;
[2/3] commons-compress git commit: Revert "fix COMPRESS-357 with a
volatile flag"
Posted by bo...@apache.org.
Revert "fix COMPRESS-357 with a volatile flag"
This reverts commit 8769bb6980ea9d46f8fbec1fa1075128d6f61936.
Project: http://git-wip-us.apache.org/repos/asf/commons-compress/repo
Commit: http://git-wip-us.apache.org/repos/asf/commons-compress/commit/f87a7ce9
Tree: http://git-wip-us.apache.org/repos/asf/commons-compress/tree/f87a7ce9
Diff: http://git-wip-us.apache.org/repos/asf/commons-compress/diff/f87a7ce9
Branch: refs/heads/master
Commit: f87a7ce9321b4901a77786387cfe8026f1249721
Parents: e9d6221
Author: Stefan Bodewig <bo...@apache.org>
Authored: Sat Jun 11 17:27:25 2016 +0200
Committer: Stefan Bodewig <bo...@apache.org>
Committed: Sat Jun 11 17:27:25 2016 +0200
----------------------------------------------------------------------
src/changes/changes.xml | 4 ++--
.../compressors/bzip2/BZip2CompressorOutputStream.java | 12 +++++-------
2 files changed, 7 insertions(+), 9 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/commons-compress/blob/f87a7ce9/src/changes/changes.xml
----------------------------------------------------------------------
diff --git a/src/changes/changes.xml b/src/changes/changes.xml
index d74fd98..eb9bb00 100644
--- a/src/changes/changes.xml
+++ b/src/changes/changes.xml
@@ -76,8 +76,8 @@ The <action> type attribute can be add,update,fix,remove.
used in Apple's iWork 13 files.
</action>
<action issue="COMPRESS-357" type="fix" date="2016-05-26">
- A race-condition between BZip2CompressorOutputStream's finish
- and finalize methods could lead to corrupted streams.
+ BZip2CompressorOutputStream#finish is now synchronized to
+ avoid a race condition with the finalize method.
</action>
<action issue="COMPRESS-351" type="update" date="2016-06-07">
ZipArchiveInputStream and CpioArchiveInputStream could throw
http://git-wip-us.apache.org/repos/asf/commons-compress/blob/f87a7ce9/src/main/java/org/apache/commons/compress/compressors/bzip2/BZip2CompressorOutputStream.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/commons/compress/compressors/bzip2/BZip2CompressorOutputStream.java b/src/main/java/org/apache/commons/compress/compressors/bzip2/BZip2CompressorOutputStream.java
index 483d844..3bdee5a 100644
--- a/src/main/java/org/apache/commons/compress/compressors/bzip2/BZip2CompressorOutputStream.java
+++ b/src/main/java/org/apache/commons/compress/compressors/bzip2/BZip2CompressorOutputStream.java
@@ -322,7 +322,6 @@ public class BZip2CompressorOutputStream extends CompressorOutputStream
private BlockSort blockSorter;
private OutputStream out;
- private volatile boolean closed;
/**
* Chooses a blocksize based on the given length of the data to compress.
@@ -393,7 +392,7 @@ public class BZip2CompressorOutputStream extends CompressorOutputStream
@Override
public void write(final int b) throws IOException {
- if (!closed) {
+ if (this.out != null) {
write0(b);
} else {
throw new IOException("closed");
@@ -477,8 +476,8 @@ public class BZip2CompressorOutputStream extends CompressorOutputStream
}
- public void finish() throws IOException {
- if (!closed) {
+ public synchronized void finish() throws IOException {
+ if (out != null) {
try {
if (this.runLength > 0) {
writeRun();
@@ -487,7 +486,6 @@ public class BZip2CompressorOutputStream extends CompressorOutputStream
endBlock();
endCompression();
} finally {
- closed = true;
this.out = null;
this.data = null;
this.blockSorter = null;
@@ -497,7 +495,7 @@ public class BZip2CompressorOutputStream extends CompressorOutputStream
@Override
public void close() throws IOException {
- if (!closed) {
+ if (out != null) {
final OutputStream outShadow = this.out;
finish();
outShadow.close();
@@ -627,7 +625,7 @@ public class BZip2CompressorOutputStream extends CompressorOutputStream
+ len + ") > buf.length("
+ buf.length + ").");
}
- if (closed) {
+ if (this.out == null) {
throw new IOException("stream closed");
}
[3/3] commons-compress git commit: COMPRESS-357 synchronize the
important part of finish again
Posted by bo...@apache.org.
COMPRESS-357 synchronize the important part of finish again
Project: http://git-wip-us.apache.org/repos/asf/commons-compress/repo
Commit: http://git-wip-us.apache.org/repos/asf/commons-compress/commit/abc2d239
Tree: http://git-wip-us.apache.org/repos/asf/commons-compress/tree/abc2d239
Diff: http://git-wip-us.apache.org/repos/asf/commons-compress/diff/abc2d239
Branch: refs/heads/master
Commit: abc2d23900ff5adeef648879af6bc4d2f79c261e
Parents: f87a7ce
Author: Stefan Bodewig <bo...@apache.org>
Authored: Sat Jun 11 17:33:15 2016 +0200
Committer: Stefan Bodewig <bo...@apache.org>
Committed: Sat Jun 11 17:33:15 2016 +0200
----------------------------------------------------------------------
.../bzip2/BZip2CompressorOutputStream.java | 27 +++++++++++---------
1 file changed, 15 insertions(+), 12 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/commons-compress/blob/abc2d239/src/main/java/org/apache/commons/compress/compressors/bzip2/BZip2CompressorOutputStream.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/commons/compress/compressors/bzip2/BZip2CompressorOutputStream.java b/src/main/java/org/apache/commons/compress/compressors/bzip2/BZip2CompressorOutputStream.java
index 3bdee5a..034fbfc 100644
--- a/src/main/java/org/apache/commons/compress/compressors/bzip2/BZip2CompressorOutputStream.java
+++ b/src/main/java/org/apache/commons/compress/compressors/bzip2/BZip2CompressorOutputStream.java
@@ -321,6 +321,7 @@ public class BZip2CompressorOutputStream extends CompressorOutputStream
private Data data;
private BlockSort blockSorter;
+ private final Object outLock = new Object();
private OutputStream out;
/**
@@ -476,21 +477,23 @@ public class BZip2CompressorOutputStream extends CompressorOutputStream
}
- public synchronized void finish() throws IOException {
- if (out != null) {
- try {
- if (this.runLength > 0) {
- writeRun();
+ public void finish() throws IOException {
+ synchronized(outLock) {
+ if (out != null) {
+ try {
+ if (this.runLength > 0) {
+ writeRun();
+ }
+ this.currentChar = -1;
+ endBlock();
+ endCompression();
+ } finally {
+ this.out = null;
}
- this.currentChar = -1;
- endBlock();
- endCompression();
- } finally {
- this.out = null;
- this.data = null;
- this.blockSorter = null;
}
}
+ this.blockSorter = null;
+ this.data = null;
}
@Override