You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by gg...@apache.org on 2022/05/05 17:19:06 UTC

[commons-compress] branch master updated (63cd3ceb -> 473d5e1c)

This is an automated email from the ASF dual-hosted git repository.

ggregory pushed a change to branch master
in repository https://gitbox.apache.org/repos/asf/commons-compress.git


    from 63cd3ceb Remove unused exception from private method signature.
     new e92befb0 Javadoc & use a ternary expression.
     new 4f5af021 ChecksumVerifyingInputStream.read() does not always validate checksum at end-of-stream.
     new 66b946e7 Sort members.
     new e1342d98 Refactor commons code.
     new 473d5e1c Bump commons.jacoco.version from 0.8.7 to 0.8.8

The 5 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:
 pom.xml                                            |  2 +-
 src/changes/changes.xml                            |  6 +++
 .../compress/utils/CRC32VerifyingInputStream.java  |  6 ++-
 .../utils/ChecksumVerifyingInputStream.java        | 50 +++++++++++++---------
 4 files changed, 41 insertions(+), 23 deletions(-)


[commons-compress] 05/05: Bump commons.jacoco.version from 0.8.7 to 0.8.8

Posted by gg...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

ggregory pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/commons-compress.git

commit 473d5e1ceaa2686cc7bf14462894496dfd779416
Author: Gary Gregory <ga...@gmail.com>
AuthorDate: Thu May 5 09:34:46 2022 -0400

    Bump commons.jacoco.version from 0.8.7 to 0.8.8
---
 pom.xml                 | 2 +-
 src/changes/changes.xml | 3 +++
 2 files changed, 4 insertions(+), 1 deletion(-)

diff --git a/pom.xml b/pom.xml
index 1aa33a05..6d44b9c5 100644
--- a/pom.xml
+++ b/pom.xml
@@ -76,7 +76,7 @@ Brotli, Zstandard and ar, cpio, jar, tar, zip, dump, 7z, arj.
     <junit.version>5.8.2</junit.version>
     <pax.exam.version>4.13.5</pax.exam.version>
     <slf4j.version>1.7.36</slf4j.version>
-    <commons.jacoco.version>0.8.7</commons.jacoco.version>
+    <commons.jacoco.version>0.8.8</commons.jacoco.version>
     <commons.japicmp.version>0.15.7</commons.japicmp.version>
     <commons.javadoc.version>3.4.0</commons.javadoc.version>
     <asm.version>9.3</asm.version>
diff --git a/src/changes/changes.xml b/src/changes/changes.xml
index fd207832..e2833331 100644
--- a/src/changes/changes.xml
+++ b/src/changes/changes.xml
@@ -179,6 +179,9 @@ The <action> type attribute can be add,update,fix,remove.
       <action type="update" dev="kinow" due-to="Dependabot">
         Bump github/codeql-action from 1 to 2 #287.
       </action>
+      <action type="update" dev="kinow" due-to="Gary Gregory">
+        Bump commons.jacoco.version from 0.8.7 to 0.8.8.
+      </action>
     </release>
     <release version="1.21" date="2021-07-12"
              description="Release 1.21 (Java 8)


[commons-compress] 04/05: Refactor commons code.

Posted by gg...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

ggregory pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/commons-compress.git

commit e1342d9849393dbe75188738b2798ff03b872954
Author: Gary Gregory <ga...@gmail.com>
AuthorDate: Thu May 5 09:29:36 2022 -0400

    Refactor commons code.
---
 .../compress/utils/ChecksumVerifyingInputStream.java      | 15 +++++++++------
 1 file changed, 9 insertions(+), 6 deletions(-)

diff --git a/src/main/java/org/apache/commons/compress/utils/ChecksumVerifyingInputStream.java b/src/main/java/org/apache/commons/compress/utils/ChecksumVerifyingInputStream.java
index 89eee317..62eca310 100644
--- a/src/main/java/org/apache/commons/compress/utils/ChecksumVerifyingInputStream.java
+++ b/src/main/java/org/apache/commons/compress/utils/ChecksumVerifyingInputStream.java
@@ -28,6 +28,7 @@ import java.util.zip.Checksum;
  * @since 1.7
  */
 public class ChecksumVerifyingInputStream extends InputStream {
+
     private final InputStream in;
     private long bytesRemaining;
     private final long expectedChecksum;
@@ -78,9 +79,7 @@ public class ChecksumVerifyingInputStream extends InputStream {
             checksum.update(ret);
             --bytesRemaining;
         }
-        if (bytesRemaining <= 0 && expectedChecksum != checksum.getValue()) {
-            throw new IOException("Checksum verification failed");
-        }
+        verify();
         return ret;
     }
 
@@ -111,9 +110,7 @@ public class ChecksumVerifyingInputStream extends InputStream {
             checksum.update(b, off, ret);
             bytesRemaining -= ret;
         }
-        if (bytesRemaining <= 0 && expectedChecksum != checksum.getValue()) {
-            throw new IOException("Checksum verification failed");
-        }
+        verify();
         return ret;
     }
 
@@ -122,4 +119,10 @@ public class ChecksumVerifyingInputStream extends InputStream {
         // Can't really skip, we have to hash everything to verify the checksum
         return read() >= 0 ? 1 : 0;
     }
+
+    private void verify() throws IOException {
+        if (bytesRemaining <= 0 && expectedChecksum != checksum.getValue()) {
+            throw new IOException("Checksum verification failed");
+        }
+    }
 }


[commons-compress] 03/05: Sort members.

Posted by gg...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

ggregory pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/commons-compress.git

commit 66b946e73f0099cdfd410cc7a360be7367ce9596
Author: Gary Gregory <ga...@gmail.com>
AuthorDate: Thu May 5 09:26:17 2022 -0400

    Sort members.
---
 .../utils/ChecksumVerifyingInputStream.java        | 26 +++++++++++-----------
 1 file changed, 13 insertions(+), 13 deletions(-)

diff --git a/src/main/java/org/apache/commons/compress/utils/ChecksumVerifyingInputStream.java b/src/main/java/org/apache/commons/compress/utils/ChecksumVerifyingInputStream.java
index cce434a0..89eee317 100644
--- a/src/main/java/org/apache/commons/compress/utils/ChecksumVerifyingInputStream.java
+++ b/src/main/java/org/apache/commons/compress/utils/ChecksumVerifyingInputStream.java
@@ -49,6 +49,19 @@ public class ChecksumVerifyingInputStream extends InputStream {
         this.bytesRemaining = size;
     }
 
+    @Override
+    public void close() throws IOException {
+        in.close();
+    }
+
+    /**
+     * @return bytes remaining to read
+     * @since 1.21
+     */
+    public long getBytesRemaining() {
+        return bytesRemaining;
+    }
+
     /**
      * Reads a single byte from the stream
      * @throws IOException if the underlying stream throws or the
@@ -109,17 +122,4 @@ public class ChecksumVerifyingInputStream extends InputStream {
         // Can't really skip, we have to hash everything to verify the checksum
         return read() >= 0 ? 1 : 0;
     }
-
-    @Override
-    public void close() throws IOException {
-        in.close();
-    }
-
-    /**
-     * @return bytes remaining to read
-     * @since 1.21
-     */
-    public long getBytesRemaining() {
-        return bytesRemaining;
-    }
 }


[commons-compress] 01/05: Javadoc & use a ternary expression.

Posted by gg...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

ggregory pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/commons-compress.git

commit e92befb0002ea07d453be86cc9cf746b99fed834
Author: Gary Gregory <ga...@gmail.com>
AuthorDate: Thu May 5 09:23:46 2022 -0400

    Javadoc & use a ternary expression.
---
 .../commons/compress/utils/CRC32VerifyingInputStream.java   |  6 +++++-
 .../compress/utils/ChecksumVerifyingInputStream.java        | 13 +++++++++----
 2 files changed, 14 insertions(+), 5 deletions(-)

diff --git a/src/main/java/org/apache/commons/compress/utils/CRC32VerifyingInputStream.java b/src/main/java/org/apache/commons/compress/utils/CRC32VerifyingInputStream.java
index 1b50e8ce..0e5bf50f 100644
--- a/src/main/java/org/apache/commons/compress/utils/CRC32VerifyingInputStream.java
+++ b/src/main/java/org/apache/commons/compress/utils/CRC32VerifyingInputStream.java
@@ -29,6 +29,8 @@ import java.util.zip.CRC32;
 public class CRC32VerifyingInputStream extends ChecksumVerifyingInputStream {
 
     /**
+     * Constructs a new instance.
+     *
      * @param in the stream to wrap
      * @param size the of the stream's content
      * @param expectedCrc32 the expected checksum
@@ -38,10 +40,12 @@ public class CRC32VerifyingInputStream extends ChecksumVerifyingInputStream {
     }
 
     /**
-     * @since 1.7
+     * Constructs a new instance.
+     *
      * @param in the stream to wrap
      * @param size the of the stream's content
      * @param expectedCrc32 the expected checksum
+     * @since 1.7
      */
     public CRC32VerifyingInputStream(final InputStream in, final long size, final long expectedCrc32) {
         super(new CRC32(), in, size, expectedCrc32);
diff --git a/src/main/java/org/apache/commons/compress/utils/ChecksumVerifyingInputStream.java b/src/main/java/org/apache/commons/compress/utils/ChecksumVerifyingInputStream.java
index 80bbabcc..c80f7c82 100644
--- a/src/main/java/org/apache/commons/compress/utils/ChecksumVerifyingInputStream.java
+++ b/src/main/java/org/apache/commons/compress/utils/ChecksumVerifyingInputStream.java
@@ -33,6 +33,14 @@ public class ChecksumVerifyingInputStream extends InputStream {
     private final long expectedChecksum;
     private final Checksum checksum;
 
+    /**
+     * Constructs a new instance.
+     *
+     * @param checksum Checksum implementation.
+     * @param in the stream to wrap
+     * @param size the of the stream's content
+     * @param expectedChecksum the expected checksum
+     */
     public ChecksumVerifyingInputStream(final Checksum checksum, final InputStream in,
                                         final long size, final long expectedChecksum) {
         this.checksum = checksum;
@@ -99,10 +107,7 @@ public class ChecksumVerifyingInputStream extends InputStream {
     @Override
     public long skip(final long n) throws IOException {
         // Can't really skip, we have to hash everything to verify the checksum
-        if (read() >= 0) {
-            return 1;
-        }
-        return 0;
+        return read() >= 0 ? 1 : 0;
     }
 
     @Override


[commons-compress] 02/05: ChecksumVerifyingInputStream.read() does not always validate checksum at end-of-stream.

Posted by gg...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

ggregory pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/commons-compress.git

commit 4f5af021834caab4dab3b08cd89db30fff6830ec
Author: Gary Gregory <ga...@gmail.com>
AuthorDate: Thu May 5 09:26:04 2022 -0400

    ChecksumVerifyingInputStream.read() does not always validate checksum at
    end-of-stream.
---
 src/changes/changes.xml                                                | 3 +++
 .../apache/commons/compress/utils/ChecksumVerifyingInputStream.java    | 2 +-
 2 files changed, 4 insertions(+), 1 deletion(-)

diff --git a/src/changes/changes.xml b/src/changes/changes.xml
index ecba8dad..fd207832 100644
--- a/src/changes/changes.xml
+++ b/src/changes/changes.xml
@@ -103,6 +103,9 @@ The <action> type attribute can be add,update,fix,remove.
       <action type="fix" dev="ggregory" due-to="Arturo Bernal">
         Avoid use C-style array declaration. #282.
       </action>
+      <action type="fix" dev="ggregory" due-to="Gary Gregory">
+        ChecksumVerifyingInputStream.read() does not always validate checksum at end-of-stream.        
+      </action>
       <!-- ADD -->
       <action issue="COMPRESS-602" type="add" dev="ggregory" due-to="Postelnicu George, Gary Gregory">
         Migrate zip package to use NIO #236.
diff --git a/src/main/java/org/apache/commons/compress/utils/ChecksumVerifyingInputStream.java b/src/main/java/org/apache/commons/compress/utils/ChecksumVerifyingInputStream.java
index c80f7c82..cce434a0 100644
--- a/src/main/java/org/apache/commons/compress/utils/ChecksumVerifyingInputStream.java
+++ b/src/main/java/org/apache/commons/compress/utils/ChecksumVerifyingInputStream.java
@@ -65,7 +65,7 @@ public class ChecksumVerifyingInputStream extends InputStream {
             checksum.update(ret);
             --bytesRemaining;
         }
-        if (bytesRemaining == 0 && expectedChecksum != checksum.getValue()) {
+        if (bytesRemaining <= 0 && expectedChecksum != checksum.getValue()) {
             throw new IOException("Checksum verification failed");
         }
         return ret;