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 2025/02/03 15:40:18 UTC

(commons-compress) branch master updated (41746ffba -> a60c3279c)

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 41746ffba [COMPRESS-692] Add support for zstd compression in zip archives
     new d71bae8a3 Use inline comments
     new a60c3279c Refactor boilerplate

The 2 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/zip/ZipArchiveOutputStream.java     | 14 +++++---------
 .../org/apache/commons/compress/archivers/zip/ZipUtil.java |  9 +++++----
 2 files changed, 10 insertions(+), 13 deletions(-)


(commons-compress) 02/02: Refactor boilerplate

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 a60c3279cbfffe078012955eb659d7ca68960b5e
Author: Gary Gregory <ga...@gmail.com>
AuthorDate: Mon Feb 3 10:40:13 2025 -0500

    Refactor boilerplate
---
 .../java/org/apache/commons/compress/archivers/zip/ZipUtil.java  | 9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)

diff --git a/src/main/java/org/apache/commons/compress/archivers/zip/ZipUtil.java b/src/main/java/org/apache/commons/compress/archivers/zip/ZipUtil.java
index f2a6f59bd..cc2841ad0 100644
--- a/src/main/java/org/apache/commons/compress/archivers/zip/ZipUtil.java
+++ b/src/main/java/org/apache/commons/compress/archivers/zip/ZipUtil.java
@@ -331,10 +331,11 @@ private static boolean supportsEncryptionOf(final ZipArchiveEntry entry) {
      * @return true if the compression method is supported
      */
     private static boolean supportsMethodOf(final ZipArchiveEntry entry) {
-        return entry.getMethod() == ZipEntry.STORED || entry.getMethod() == ZipMethod.UNSHRINKING.getCode()
-                || entry.getMethod() == ZipMethod.IMPLODING.getCode() || entry.getMethod() == ZipEntry.DEFLATED
-                || entry.getMethod() == ZipMethod.ENHANCED_DEFLATED.getCode() || entry.getMethod() == ZipMethod.BZIP2.getCode()
-                || entry.getMethod() == ZipMethod.ZSTD.getCode() || entry.getMethod() == ZipMethod.ZSTD_DEPRECATED.getCode();
+        final int method = entry.getMethod();
+        return method == ZipEntry.STORED || method == ZipMethod.UNSHRINKING.getCode()
+                || method == ZipMethod.IMPLODING.getCode() || method == ZipEntry.DEFLATED
+                || method == ZipMethod.ENHANCED_DEFLATED.getCode() || method == ZipMethod.BZIP2.getCode()
+                || method == ZipMethod.ZSTD.getCode() || method == ZipMethod.ZSTD_DEPRECATED.getCode();
     }
 
     /**


(commons-compress) 01/02: Use inline comments

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 d71bae8a3d0222dad10d9acff00b54e31b270e0d
Author: Gary Gregory <ga...@gmail.com>
AuthorDate: Mon Feb 3 10:38:53 2025 -0500

    Use inline comments
    
    Reduce whitespace
---
 .../compress/archivers/zip/ZipArchiveOutputStream.java     | 14 +++++---------
 1 file changed, 5 insertions(+), 9 deletions(-)

diff --git a/src/main/java/org/apache/commons/compress/archivers/zip/ZipArchiveOutputStream.java b/src/main/java/org/apache/commons/compress/archivers/zip/ZipArchiveOutputStream.java
index d945f7442..95badc9ee 100644
--- a/src/main/java/org/apache/commons/compress/archivers/zip/ZipArchiveOutputStream.java
+++ b/src/main/java/org/apache/commons/compress/archivers/zip/ZipArchiveOutputStream.java
@@ -1071,31 +1071,27 @@ private Zip64ExtendedInformationExtraField getZip64Extra(final ZipArchiveEntry z
      */
     private boolean handleSizesAndCrc(final long bytesWritten, final long crc, final Zip64Mode effectiveMode) throws ZipException {
         if (entry.entry.getMethod() == DEFLATED) {
-            /*
-             * It turns out def.getBytesRead() returns wrong values if the size exceeds 4 GB on Java < Java7 entry.entry.setSize(def.getBytesRead());
-             */
+            // It turns out def.getBytesRead() returns wrong values if the size exceeds 4 GB on Java < Java7 entry.entry.setSize(def.getBytesRead());
             entry.entry.setSize(entry.bytesRead);
             entry.entry.setCompressedSize(bytesWritten);
             entry.entry.setCrc(crc);
-
         } else if (entry.entry.getMethod() == ZipMethod.ZSTD.getCode() || entry.entry.getMethod() == ZipMethod.ZSTD_DEPRECATED.getCode()) {
             entry.entry.setCompressedSize(bytesWritten);
             entry.entry.setCrc(crc);
         } else if (!(out instanceof RandomAccessOutputStream)) {
             if (entry.entry.getCrc() != crc) {
-                throw new ZipException("Bad CRC checksum for entry " + entry.entry.getName() + ": " + Long.toHexString(entry.entry.getCrc()) + " instead of "
-                        + Long.toHexString(crc));
+                throw new ZipException("Bad CRC checksum for entry " + entry.entry.getName() + ": " + Long.toHexString(entry.entry.getCrc()) + " instead of " +
+                        Long.toHexString(crc));
             }
-
             if (entry.entry.getSize() != bytesWritten) {
                 throw new ZipException("Bad size for entry " + entry.entry.getName() + ": " + entry.entry.getSize() + " instead of " + bytesWritten);
             }
-        } else { /* method is STORED and we used SeekableByteChannel */
+        } else {
+            // method is STORED and we used SeekableByteChannel
             entry.entry.setSize(bytesWritten);
             entry.entry.setCompressedSize(bytesWritten);
             entry.entry.setCrc(crc);
         }
-
         return checkIfNeedsZip64(effectiveMode);
     }