commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bode...@apache.org
Subject commons-compress git commit: COMPRESS-207 ensure notification of first block
Date Mon, 28 Mar 2016 08:46:28 GMT
Repository: commons-compress
Updated Branches:
  refs/heads/COMPRESS-207 8b1908cbb -> e1a895a0f


COMPRESS-207 ensure notification of first block

The START_BLOCK_STATE is only ever current right at the start or at the
end of initBlock(). initBlock() is always followed by setupBlock() which
immediately sets the current state to a different
state (RAND_PART_B_STATE, NO_RAND_PART_B_STATE or EOF).


Project: http://git-wip-us.apache.org/repos/asf/commons-compress/repo
Commit: http://git-wip-us.apache.org/repos/asf/commons-compress/commit/e1a895a0
Tree: http://git-wip-us.apache.org/repos/asf/commons-compress/tree/e1a895a0
Diff: http://git-wip-us.apache.org/repos/asf/commons-compress/diff/e1a895a0

Branch: refs/heads/COMPRESS-207
Commit: e1a895a0f38075dcebe143c8baf6fe701cf113a1
Parents: 8b1908c
Author: Stefan Bodewig <bodewig@apache.org>
Authored: Mon Mar 28 10:43:15 2016 +0200
Committer: Stefan Bodewig <bodewig@apache.org>
Committed: Mon Mar 28 10:43:15 2016 +0200

----------------------------------------------------------------------
 .../bzip2/BZip2CompressorInputStream.java       |  2 +-
 .../compress/compressors/BZip2TestCase.java     | 32 +++++++++++---------
 2 files changed, 18 insertions(+), 16 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/commons-compress/blob/e1a895a0/src/main/java/org/apache/commons/compress/compressors/bzip2/BZip2CompressorInputStream.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/commons/compress/compressors/bzip2/BZip2CompressorInputStream.java
b/src/main/java/org/apache/commons/compress/compressors/bzip2/BZip2CompressorInputStream.java
index 69f395c..9c36e81 100644
--- a/src/main/java/org/apache/commons/compress/compressors/bzip2/BZip2CompressorInputStream.java
+++ b/src/main/java/org/apache/commons/compress/compressors/bzip2/BZip2CompressorInputStream.java
@@ -134,7 +134,6 @@ public class BZip2CompressorInputStream extends CompressorInputStream
implements
         this.decompressConcatenated = decompressConcatenated;
 
         init(true);
-        initBlock();
     }
 
     @Override
@@ -206,6 +205,7 @@ public class BZip2CompressorInputStream extends CompressorInputStream
implements
             return -1;
 
         case START_BLOCK_STATE:
+            initBlock();
             return setupBlock();
 
         case RAND_PART_A_STATE:

http://git-wip-us.apache.org/repos/asf/commons-compress/blob/e1a895a0/src/test/java/org/apache/commons/compress/compressors/BZip2TestCase.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/commons/compress/compressors/BZip2TestCase.java b/src/test/java/org/apache/commons/compress/compressors/BZip2TestCase.java
index 17e6554..10c3e89 100644
--- a/src/test/java/org/apache/commons/compress/compressors/BZip2TestCase.java
+++ b/src/test/java/org/apache/commons/compress/compressors/BZip2TestCase.java
@@ -158,23 +158,25 @@ public final class BZip2TestCase extends AbstractTestCase {
         while(in.read() >= 0);
         in.close();
 
-        // we miss the initial block event which is triggered by the constructor
-        assertEquals(4, blockNumbers.size());
-        for (int i = 0; i < 4; i++) {
-            assertEquals(i + 1, blockNumbers.get(i).intValue());
+        assertEquals(5, blockNumbers.size());
+        for (int i = 0; i < 5; i++) {
+            assertEquals(i, blockNumbers.get(i).intValue());
         }
 
-        assertEquals(4, uncompressedBytes.size());
-        assertEquals(Long.valueOf(899907), uncompressedBytes.get(0));
-        assertEquals(Long.valueOf(1799817), uncompressedBytes.get(1));
-        assertEquals(Long.valueOf(2699710), uncompressedBytes.get(2));
-        assertEquals(Long.valueOf(3599604), uncompressedBytes.get(3));
-
-        assertEquals(4, compressedBytes.size());
-        assertEquals(Long.valueOf(457766), compressedBytes.get(0));
-        assertEquals(Long.valueOf(915639), compressedBytes.get(1));
-        assertEquals(Long.valueOf(1373360), compressedBytes.get(2));
-        assertEquals(Long.valueOf(1831305), compressedBytes.get(3));
+        assertEquals(5, uncompressedBytes.size());
+        assertEquals(Long.valueOf(0), uncompressedBytes.get(0));
+        assertEquals(Long.valueOf(899907), uncompressedBytes.get(1));
+        assertEquals(Long.valueOf(1799817), uncompressedBytes.get(2));
+        assertEquals(Long.valueOf(2699710), uncompressedBytes.get(3));
+        assertEquals(Long.valueOf(3599604), uncompressedBytes.get(4));
+
+        assertEquals(5, compressedBytes.size());
+        // 4 == number of magic bytes + blocksize
+        assertEquals(Long.valueOf(4), compressedBytes.get(0));
+        assertEquals(Long.valueOf(457766), compressedBytes.get(1));
+        assertEquals(Long.valueOf(915639), compressedBytes.get(2));
+        assertEquals(Long.valueOf(1373360), compressedBytes.get(3));
+        assertEquals(Long.valueOf(1831305), compressedBytes.get(4));
     }
 
 }


Mime
View raw message