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 2019/09/01 14:10:12 UTC
[commons-compress] branch master updated (d3a0a30 -> 9eeea3f)
This is an automated email from the ASF dual-hosted git repository.
bodewig pushed a change to branch master
in repository https://gitbox.apache.org/repos/asf/commons-compress.git.
from d3a0a30 COMPRESS-491 InputStream contract says "return 0 if length is 0, don't try to read"
new 2488a44 COMPRESS-491 overlooked the code was already checking for 0 len
new 5eb6b35 the if the comment is talking about has gone a while ago
new fbaba0e non-blocking ReadableByteChannels may return 0 on read
new 9eeea3f COMPRESS-491 avoid returning 0 from read in Deflat64 input stream
The 4 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails. The revisions
listed as "add" were already present in the repository and have only
been added to this reference.
Summary of changes:
.../compress/archivers/cpio/CpioArchiveInputStream.java | 3 ---
.../sevenz/BoundedSeekableByteChannelInputStream.java | 11 +++++++++++
.../compressors/bzip2/BZip2CompressorInputStream.java | 3 ---
.../compress/compressors/deflate64/HuffmanDecoder.java | 5 ++++-
.../compress/compressors/gzip/GzipCompressorInputStream.java | 3 ---
.../compress/compressors/deflate64/HuffmanDecoderTest.java | 3 ---
6 files changed, 15 insertions(+), 13 deletions(-)
[commons-compress] 01/04: COMPRESS-491 overlooked the code was
already checking for 0 len
Posted by bo...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
bodewig pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/commons-compress.git
commit 2488a44faec06a91ae52652407fb0a881ed217d2
Author: Stefan Bodewig <bo...@apache.org>
AuthorDate: Sat Aug 31 15:15:44 2019 +0200
COMPRESS-491 overlooked the code was already checking for 0 len
---
.../apache/commons/compress/archivers/cpio/CpioArchiveInputStream.java | 3 ---
.../commons/compress/compressors/bzip2/BZip2CompressorInputStream.java | 3 ---
2 files changed, 6 deletions(-)
diff --git a/src/main/java/org/apache/commons/compress/archivers/cpio/CpioArchiveInputStream.java b/src/main/java/org/apache/commons/compress/archivers/cpio/CpioArchiveInputStream.java
index e9406eb..da20cf8 100644
--- a/src/main/java/org/apache/commons/compress/archivers/cpio/CpioArchiveInputStream.java
+++ b/src/main/java/org/apache/commons/compress/archivers/cpio/CpioArchiveInputStream.java
@@ -303,9 +303,6 @@ public class CpioArchiveInputStream extends ArchiveInputStream implements
@Override
public int read(final byte[] b, final int off, final int len)
throws IOException {
- if (len == 0) {
- return 0;
- }
ensureOpen();
if (off < 0 || len < 0 || off > b.length - len) {
throw new IndexOutOfBoundsException();
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 cd82a99..1a5e2ab 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
@@ -154,9 +154,6 @@ public class BZip2CompressorInputStream extends CompressorInputStream
@Override
public int read(final byte[] dest, final int offs, final int len)
throws IOException {
- if (len == 0) {
- return 0;
- }
if (offs < 0) {
throw new IndexOutOfBoundsException("offs(" + offs + ") < 0.");
}
[commons-compress] 03/04: non-blocking ReadableByteChannels may
return 0 on read
Posted by bo...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
bodewig pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/commons-compress.git
commit fbaba0eab63bae94c865e6ba91295b79c8e8cbc1
Author: Stefan Bodewig <bo...@apache.org>
AuthorDate: Sun Sep 1 14:54:36 2019 +0200
non-blocking ReadableByteChannels may return 0 on read
---
.../sevenz/BoundedSeekableByteChannelInputStream.java | 11 +++++++++++
1 file changed, 11 insertions(+)
diff --git a/src/main/java/org/apache/commons/compress/archivers/sevenz/BoundedSeekableByteChannelInputStream.java b/src/main/java/org/apache/commons/compress/archivers/sevenz/BoundedSeekableByteChannelInputStream.java
index 3b3689e..203f5fb 100644
--- a/src/main/java/org/apache/commons/compress/archivers/sevenz/BoundedSeekableByteChannelInputStream.java
+++ b/src/main/java/org/apache/commons/compress/archivers/sevenz/BoundedSeekableByteChannelInputStream.java
@@ -52,6 +52,17 @@ class BoundedSeekableByteChannelInputStream extends InputStream {
return -1;
}
+ /**
+ * Reads up to len bytes of data from the input stream into an array of bytes.
+ *
+ * <p>An attempt is made to read as many as len bytes, but a
+ * smaller number may be read. The number of bytes actually read
+ * is returned as an integer.</p>
+ *
+ * <p>This implementation may return 0 if the underlying {@link
+ * SeekableByteChannel} is non-blocking and currently hasn't got
+ * any bytes available.</p>
+ */
@Override
public int read(final byte[] b, final int off, final int len) throws IOException {
if (len == 0) {
[commons-compress] 02/04: the if the comment is talking about has
gone a while ago
Posted by bo...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
bodewig pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/commons-compress.git
commit 5eb6b35d4e31a4468d34164ad7f971807188cb3e
Author: Stefan Bodewig <bo...@apache.org>
AuthorDate: Sun Sep 1 14:54:14 2019 +0200
the if the comment is talking about has gone a while ago
---
.../commons/compress/compressors/gzip/GzipCompressorInputStream.java | 3 ---
1 file changed, 3 deletions(-)
diff --git a/src/main/java/org/apache/commons/compress/compressors/gzip/GzipCompressorInputStream.java b/src/main/java/org/apache/commons/compress/compressors/gzip/GzipCompressorInputStream.java
index ed47982..eaf6482 100644
--- a/src/main/java/org/apache/commons/compress/compressors/gzip/GzipCompressorInputStream.java
+++ b/src/main/java/org/apache/commons/compress/compressors/gzip/GzipCompressorInputStream.java
@@ -325,9 +325,6 @@ public class GzipCompressorInputStream extends CompressorInputStream
if (inf.finished()) {
// We may have read too many bytes. Rewind the read
// position to match the actual amount used.
- //
- // NOTE: The "if" is there just in case. Since we used
- // in.mark earlier, it should always skip enough.
in.reset();
final int skipAmount = bufUsed - inf.getRemaining();
[commons-compress] 04/04: COMPRESS-491 avoid returning 0 from read
in Deflat64 input stream
Posted by bo...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
bodewig pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/commons-compress.git
commit 9eeea3f3c0b4abbdb357200d0f3ba8e4863545e7
Author: Stefan Bodewig <bo...@apache.org>
AuthorDate: Sun Sep 1 16:09:36 2019 +0200
COMPRESS-491 avoid returning 0 from read in Deflat64 input stream
---
.../commons/compress/compressors/deflate64/HuffmanDecoder.java | 5 ++++-
.../commons/compress/compressors/deflate64/HuffmanDecoderTest.java | 3 ---
2 files changed, 4 insertions(+), 4 deletions(-)
diff --git a/src/main/java/org/apache/commons/compress/compressors/deflate64/HuffmanDecoder.java b/src/main/java/org/apache/commons/compress/compressors/deflate64/HuffmanDecoder.java
index 1df6e3c..62715f3 100644
--- a/src/main/java/org/apache/commons/compress/compressors/deflate64/HuffmanDecoder.java
+++ b/src/main/java/org/apache/commons/compress/compressors/deflate64/HuffmanDecoder.java
@@ -149,7 +149,10 @@ class HuffmanDecoder implements Closeable {
throw new IllegalStateException("Unsupported compression: " + mode);
}
} else {
- return state.read(b, off, len);
+ int r = state.read(b, off, len);
+ if (r != 0) {
+ return r;
+ }
}
}
return -1;
diff --git a/src/test/java/org/apache/commons/compress/compressors/deflate64/HuffmanDecoderTest.java b/src/test/java/org/apache/commons/compress/compressors/deflate64/HuffmanDecoderTest.java
index 57249f0..bbfcd4c 100644
--- a/src/test/java/org/apache/commons/compress/compressors/deflate64/HuffmanDecoderTest.java
+++ b/src/test/java/org/apache/commons/compress/compressors/deflate64/HuffmanDecoderTest.java
@@ -214,9 +214,6 @@ public class HuffmanDecoderTest {
assertEquals("Hello World\nHello World\nHello World\nHello World\n", new String(result, 0, len));
len = decoder.decode(result);
- assertEquals(0, len);
-
- len = decoder.decode(result);
assertEquals(-1, len);
}
}