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 2024/01/16 20:27:11 UTC

(commons-compress) branch master updated (7d4beb194 -> 8f9bddc1f)

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 7d4beb194 Add ArchiveInputStream.getCharset()
     new 8a9ceaab7 Use propagated exception API
     new 4dbdecf4d Better local names
     new 8f9bddc1f Flip private argument like JUnit assertions

The 3 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:
 .../commons/compress/archivers/dump/DumpArchiveException.java  |  6 +++---
 .../apache/commons/compress/archivers/zip/ExtraFieldUtils.java |  8 ++++----
 .../commons/compress/archivers/zip/ZipArchiveInputStream.java  | 10 +++++-----
 .../org/apache/commons/compress/archivers/zip/ZipFile.java     |  8 ++++----
 4 files changed, 16 insertions(+), 16 deletions(-)


(commons-compress) 03/03: Flip private argument like JUnit assertions

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 8f9bddc1f6e091b041fe8b30f8056ded0e6b2acd
Author: Gary Gregory <ga...@gmail.com>
AuthorDate: Tue Jan 16 15:27:05 2024 -0500

    Flip private argument like JUnit assertions
---
 .../commons/compress/archivers/zip/ZipArchiveInputStream.java  | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/src/main/java/org/apache/commons/compress/archivers/zip/ZipArchiveInputStream.java b/src/main/java/org/apache/commons/compress/archivers/zip/ZipArchiveInputStream.java
index 01a06c2fa..84c43a852 100644
--- a/src/main/java/org/apache/commons/compress/archivers/zip/ZipArchiveInputStream.java
+++ b/src/main/java/org/apache/commons/compress/archivers/zip/ZipArchiveInputStream.java
@@ -207,7 +207,7 @@ public class ZipArchiveInputStream extends ArchiveInputStream<ZipArchiveEntry> i
 
     private static final BigInteger LONG_MAX = BigInteger.valueOf(Long.MAX_VALUE);
 
-    private static boolean checksig(final byte[] signature, final byte[] expected) {
+    private static boolean checksig(final byte[] expected, final byte[] signature) {
         for (int i = 0; i < expected.length; i++) {
             if (signature[i] != expected[i]) {
                 return false;
@@ -228,10 +228,10 @@ public class ZipArchiveInputStream extends ArchiveInputStream<ZipArchiveEntry> i
             return false;
         }
 
-        return checksig(signature, ZipArchiveOutputStream.LFH_SIG) // normal file
-                || checksig(signature, ZipArchiveOutputStream.EOCD_SIG) // empty zip
-                || checksig(signature, ZipArchiveOutputStream.DD_SIG) // split zip
-                || checksig(signature, ZipLong.SINGLE_SEGMENT_SPLIT_MARKER.getBytes());
+        return checksig(ZipArchiveOutputStream.LFH_SIG, signature) // normal file
+                || checksig(ZipArchiveOutputStream.EOCD_SIG, signature) // empty zip
+                || checksig(ZipArchiveOutputStream.DD_SIG, signature) // split zip
+                || checksig(ZipLong.SINGLE_SEGMENT_SPLIT_MARKER.getBytes(), signature);
     }
 
     /** The ZIP encoding to use for file names and the file comment. */


(commons-compress) 02/03: Better local names

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 4dbdecf4dac276b9463fd2943002907c475c39a7
Author: Gary Gregory <ga...@gmail.com>
AuthorDate: Tue Jan 16 15:20:38 2024 -0500

    Better local names
---
 .../apache/commons/compress/archivers/zip/ExtraFieldUtils.java    | 8 ++++----
 .../java/org/apache/commons/compress/archivers/zip/ZipFile.java   | 8 ++++----
 2 files changed, 8 insertions(+), 8 deletions(-)

diff --git a/src/main/java/org/apache/commons/compress/archivers/zip/ExtraFieldUtils.java b/src/main/java/org/apache/commons/compress/archivers/zip/ExtraFieldUtils.java
index 4dc6cb85d..a90131b19 100644
--- a/src/main/java/org/apache/commons/compress/archivers/zip/ExtraFieldUtils.java
+++ b/src/main/java/org/apache/commons/compress/archivers/zip/ExtraFieldUtils.java
@@ -198,9 +198,9 @@ public class ExtraFieldUtils {
                 ze.parseFromCentralDirectoryData(data, off, len);
             }
             return ze;
-        } catch (final ArrayIndexOutOfBoundsException aiobe) {
+        } catch (final ArrayIndexOutOfBoundsException e) {
             throw (ZipException) new ZipException("Failed to parse corrupt ZIP extra field of type " + Integer.toHexString(ze.getHeaderId().getValue()))
-                    .initCause(aiobe);
+                    .initCause(e);
         }
     }
 
@@ -332,8 +332,8 @@ public class ExtraFieldUtils {
                 final ZipExtraField ze = Objects.requireNonNull(parsingBehavior.createExtraField(headerId), "createExtraField must not return null");
                 v.add(Objects.requireNonNull(parsingBehavior.fill(ze, data, start + WORD, length, local), "fill must not return null"));
                 start += length + WORD;
-            } catch (final InstantiationException | IllegalAccessException ie) {
-                throw (ZipException) new ZipException(ie.getMessage()).initCause(ie);
+            } catch (final InstantiationException | IllegalAccessException e) {
+                throw (ZipException) new ZipException(e.getMessage()).initCause(e);
             }
         }
 
diff --git a/src/main/java/org/apache/commons/compress/archivers/zip/ZipFile.java b/src/main/java/org/apache/commons/compress/archivers/zip/ZipFile.java
index bd452e5f9..b7a6bcdd3 100644
--- a/src/main/java/org/apache/commons/compress/archivers/zip/ZipFile.java
+++ b/src/main/java/org/apache/commons/compress/archivers/zip/ZipFile.java
@@ -1490,9 +1490,9 @@ public class ZipFile implements Closeable {
         }
         try {
             ze.setCentralDirectoryExtra(cdExtraData);
-        } catch (final RuntimeException ex) {
+        } catch (final RuntimeException e) {
             final ZipException z = new ZipException("Invalid extra data in entry " + ze.getName());
-            z.initCause(ex);
+            z.initCause(e);
             throw z;
         }
 
@@ -1532,9 +1532,9 @@ public class ZipFile implements Closeable {
             }
             try {
                 ze.setExtra(localExtraData);
-            } catch (final RuntimeException ex) {
+            } catch (final RuntimeException e) {
                 final ZipException z = new ZipException("Invalid extra data in entry " + ze.getName());
-                z.initCause(ex);
+                z.initCause(e);
                 throw z;
             }
 


(commons-compress) 01/03: Use propagated exception API

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 8a9ceaab751ec93e6b98d5cf855b5cea493d845c
Author: Gary Gregory <ga...@gmail.com>
AuthorDate: Tue Jan 16 15:20:24 2024 -0500

    Use propagated exception API
---
 .../commons/compress/archivers/dump/DumpArchiveException.java       | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/src/main/java/org/apache/commons/compress/archivers/dump/DumpArchiveException.java b/src/main/java/org/apache/commons/compress/archivers/dump/DumpArchiveException.java
index 2200673a0..636585397 100644
--- a/src/main/java/org/apache/commons/compress/archivers/dump/DumpArchiveException.java
+++ b/src/main/java/org/apache/commons/compress/archivers/dump/DumpArchiveException.java
@@ -24,6 +24,7 @@ import java.io.IOException;
  * Dump Archive Exception
  */
 public class DumpArchiveException extends IOException {
+
     private static final long serialVersionUID = 1L;
 
     public DumpArchiveException() {
@@ -34,11 +35,10 @@ public class DumpArchiveException extends IOException {
     }
 
     public DumpArchiveException(final String msg, final Throwable cause) {
-        super(msg);
-        initCause(cause);
+        super(msg, cause);
     }
 
     public DumpArchiveException(final Throwable cause) {
-        initCause(cause);
+        super(cause);
     }
 }