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: avoid returning 0 from read(b, off, len)
Date Mon, 08 May 2017 10:44:07 GMT
Repository: commons-compress
Updated Branches:
  refs/heads/master 0eccda844 -> 4ac67bf32


avoid returning 0 from read(b, off, len)

while debugging what seemed to be a bug inside the compress antlib it
looks as if BufferedInputStream would translate a 0 return value into
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/4ac67bf3
Tree: http://git-wip-us.apache.org/repos/asf/commons-compress/tree/4ac67bf3
Diff: http://git-wip-us.apache.org/repos/asf/commons-compress/diff/4ac67bf3

Branch: refs/heads/master
Commit: 4ac67bf326c1494126161b18612bb62975246ab2
Parents: 0eccda8
Author: Stefan Bodewig <bodewig@apache.org>
Authored: Mon May 8 12:42:26 2017 +0200
Committer: Stefan Bodewig <bodewig@apache.org>
Committed: Mon May 8 12:42:26 2017 +0200

----------------------------------------------------------------------
 .../compress/compressors/lz4/BlockLZ4CompressorInputStream.java  | 4 ++--
 .../compress/compressors/snappy/SnappyCompressorInputStream.java | 4 ++--
 2 files changed, 4 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/commons-compress/blob/4ac67bf3/src/main/java/org/apache/commons/compress/compressors/lz4/BlockLZ4CompressorInputStream.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/commons/compress/compressors/lz4/BlockLZ4CompressorInputStream.java
b/src/main/java/org/apache/commons/compress/compressors/lz4/BlockLZ4CompressorInputStream.java
index f7d01d8..f0903a4 100644
--- a/src/main/java/org/apache/commons/compress/compressors/lz4/BlockLZ4CompressorInputStream.java
+++ b/src/main/java/org/apache/commons/compress/compressors/lz4/BlockLZ4CompressorInputStream.java
@@ -72,7 +72,7 @@ public class BlockLZ4CompressorInputStream extends AbstractLZ77CompressorInputSt
             if (!hasMoreDataInBlock()) {
                 state = State.LOOKING_FOR_BACK_REFERENCE;
             }
-            return litLen;
+            return litLen > 0 ? litLen : read(b, off, len);
         case LOOKING_FOR_BACK_REFERENCE:
             if (!initializeBackReference()) {
                 state = State.EOF;
@@ -84,7 +84,7 @@ public class BlockLZ4CompressorInputStream extends AbstractLZ77CompressorInputSt
             if (!hasMoreDataInBlock()) {
                 state = State.NO_BLOCK;
             }
-            return backReferenceLen;
+            return backReferenceLen > 0 ? backReferenceLen : read(b, off, len);
         default:
             throw new IOException("Unknown stream state " + state);
         }

http://git-wip-us.apache.org/repos/asf/commons-compress/blob/4ac67bf3/src/main/java/org/apache/commons/compress/compressors/snappy/SnappyCompressorInputStream.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/commons/compress/compressors/snappy/SnappyCompressorInputStream.java
b/src/main/java/org/apache/commons/compress/compressors/snappy/SnappyCompressorInputStream.java
index 8c9efd0..043c2ad 100644
--- a/src/main/java/org/apache/commons/compress/compressors/snappy/SnappyCompressorInputStream.java
+++ b/src/main/java/org/apache/commons/compress/compressors/snappy/SnappyCompressorInputStream.java
@@ -102,13 +102,13 @@ public class SnappyCompressorInputStream extends AbstractLZ77CompressorInputStre
             if (!hasMoreDataInBlock()) {
                 state = State.NO_BLOCK;
             }
-            return litLen;
+            return litLen > 0 ? litLen : read(b, off, len);
         case IN_BACK_REFERENCE:
             int backReferenceLen = readBackReference(b, off, len);
             if (!hasMoreDataInBlock()) {
                 state = State.NO_BLOCK;
             }
-            return backReferenceLen;
+            return backReferenceLen > 0 ? backReferenceLen : read(b, off, len);
         default:
             throw new IOException("Unknown stream state " + state);
         }


Mime
View raw message