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/05 13:30:14 UTC

(commons-compress) branch master updated (b8ea063ae -> 5c82205ff)

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 b8ea063ae Add missing assertion for XZ compressed ZIP entry
     new 03fc17143 better comment
     new 4b148974a Javadoc
     new 1461db542 Package-private class doesn't need Javadoc since tag
     new 5c82205ff Package-private and private classes can be final

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:
 src/changes/changes.xml                            |  1 +
 .../compress/archivers/ArchiveInputStream.java     |  4 +-
 .../archivers/dump/DumpArchiveConstants.java       | 61 ++++++++++++++++++----
 .../compress/archivers/dump/DumpArchiveEntry.java  | 19 ++++---
 .../commons/compress/archivers/sevenz/Coders.java  | 16 +++---
 .../commons/compress/archivers/zip/BinaryTree.java |  2 +-
 .../zip/FileRandomAccessOutputStream.java          |  2 +-
 .../compress/archivers/zip/PKWareExtraHeader.java  |  8 +--
 .../SeekableChannelRandomAccessOutputStream.java   |  2 +-
 .../commons/compress/archivers/zip/ZipFile.java    |  2 +-
 .../commons/compress/archivers/zip/ZipIoUtil.java  |  2 +-
 .../commons/compress/archivers/zip/ZipMethod.java  |  6 +--
 .../commons/compress/harmony/pack200/Archive.java  |  4 +-
 .../commons/compress/harmony/pack200/IcBands.java  |  2 +-
 .../archivers/zip/ZipCompressMethodXzTest.java     |  2 +-
 15 files changed, 92 insertions(+), 41 deletions(-)


(commons-compress) 04/04: Package-private and private classes can be final

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 5c82205ff46cf46e3eafc04a380f1ceaa16cb489
Author: Gary Gregory <ga...@gmail.com>
AuthorDate: Wed Feb 5 08:30:08 2025 -0500

    Package-private and private classes can be final
---
 src/changes/changes.xml                                  |  1 +
 .../commons/compress/archivers/ArchiveInputStream.java   |  2 +-
 .../compress/archivers/dump/DumpArchiveEntry.java        |  2 +-
 .../apache/commons/compress/archivers/sevenz/Coders.java | 16 +++++++++-------
 .../archivers/zip/FileRandomAccessOutputStream.java      |  2 +-
 .../zip/SeekableChannelRandomAccessOutputStream.java     |  2 +-
 .../apache/commons/compress/archivers/zip/ZipFile.java   |  2 +-
 .../apache/commons/compress/archivers/zip/ZipIoUtil.java |  2 +-
 .../apache/commons/compress/harmony/pack200/Archive.java |  4 ++--
 .../apache/commons/compress/harmony/pack200/IcBands.java |  2 +-
 10 files changed, 19 insertions(+), 16 deletions(-)

diff --git a/src/changes/changes.xml b/src/changes/changes.xml
index fe609e703..ca3405851 100644
--- a/src/changes/changes.xml
+++ b/src/changes/changes.xml
@@ -66,6 +66,7 @@ The <action> type attribute can be add,update,fix,remove.
       <action type="fix" dev="ggregory" due-to="Gary Gregory">Fix Javadoc and names in the org.apache.commons.compress.compressors.lzw package to specify kibibyte scale in memory limits.</action>
       <action type="fix" dev="ggregory" due-to="Gary Gregory">Fix Javadoc and names in the org.apache.commons.compress.compressors.z package to specify kibibyte scale in memory limits.</action>
       <action type="fix" dev="ggregory" due-to="Gary Gregory">Refactor LZ77Compressor block classes to reduce duplication.</action>
+      <action type="fix" dev="ggregory" due-to="Gary Gregory">Package-private and private classes can be final.</action>
       <!-- ADD -->
       <action type="add" dev="ggregory" due-to="Gary Gregory">Add GzipParameters.getModificationInstant().</action>
       <action type="add" dev="ggregory" due-to="Gary Gregory">Add GzipParameters.setModificationInstant(Instant).</action>
diff --git a/src/main/java/org/apache/commons/compress/archivers/ArchiveInputStream.java b/src/main/java/org/apache/commons/compress/archivers/ArchiveInputStream.java
index 03b2cec78..ef4239993 100644
--- a/src/main/java/org/apache/commons/compress/archivers/ArchiveInputStream.java
+++ b/src/main/java/org/apache/commons/compress/archivers/ArchiveInputStream.java
@@ -54,7 +54,7 @@ public abstract class ArchiveInputStream<E extends ArchiveEntry> extends FilterI
     /**
      * An iterator over a collection of a specific {@link ArchiveEntry} type.
      */
-    class ArchiveEntryIOIterator implements IOIterator<E> {
+    final class ArchiveEntryIOIterator implements IOIterator<E> {
 
         private E next;
 
diff --git a/src/main/java/org/apache/commons/compress/archivers/dump/DumpArchiveEntry.java b/src/main/java/org/apache/commons/compress/archivers/dump/DumpArchiveEntry.java
index 0af0681a6..a792e65cc 100644
--- a/src/main/java/org/apache/commons/compress/archivers/dump/DumpArchiveEntry.java
+++ b/src/main/java/org/apache/commons/compress/archivers/dump/DumpArchiveEntry.java
@@ -268,7 +268,7 @@ public static Set<PERMISSION> find(final int code) {
     /**
      * Archive entry as stored on tape. There is one TSH for (at most) every 512k in the file.
      */
-    static class TapeSegmentHeader {
+    static final class TapeSegmentHeader {
         private DumpArchiveConstants.SEGMENT_TYPE type;
         private int volume;
         private int ino;
diff --git a/src/main/java/org/apache/commons/compress/archivers/sevenz/Coders.java b/src/main/java/org/apache/commons/compress/archivers/sevenz/Coders.java
index 4197e98ba..b61f44f03 100644
--- a/src/main/java/org/apache/commons/compress/archivers/sevenz/Coders.java
+++ b/src/main/java/org/apache/commons/compress/archivers/sevenz/Coders.java
@@ -46,7 +46,8 @@
 import org.tukaani.xz.X86Options;
 
 final class Coders {
-    static class BCJDecoder extends AbstractCoder {
+
+    static final class BCJDecoder extends AbstractCoder {
         private final FilterOptions opts;
 
         BCJDecoder(final FilterOptions opts) {
@@ -71,7 +72,7 @@ OutputStream encode(final OutputStream out, final Object options) {
         }
     }
 
-    static class BZIP2Decoder extends AbstractCoder {
+    static final class BZIP2Decoder extends AbstractCoder {
         BZIP2Decoder() {
             super(Number.class);
         }
@@ -89,7 +90,7 @@ OutputStream encode(final OutputStream out, final Object options) throws IOExcep
         }
     }
 
-    static class CopyDecoder extends AbstractCoder {
+    static final class CopyDecoder extends AbstractCoder {
         @Override
         InputStream decode(final String archiveName, final InputStream in, final long uncompressedLength, final Coder coder, final byte[] password,
                 final int maxMemoryLimitKiB) throws IOException {
@@ -102,7 +103,7 @@ OutputStream encode(final OutputStream out, final Object options) {
         }
     }
 
-    static class Deflate64Decoder extends AbstractCoder {
+    static final class Deflate64Decoder extends AbstractCoder {
         Deflate64Decoder() {
             super(Number.class);
         }
@@ -114,8 +115,9 @@ InputStream decode(final String archiveName, final InputStream in, final long un
         }
     }
 
-    static class DeflateDecoder extends AbstractCoder {
-        static class DeflateDecoderInputStream extends FilterInputStream {
+    static final class DeflateDecoder extends AbstractCoder {
+
+        static final class DeflateDecoderInputStream extends FilterInputStream {
 
             Inflater inflater;
 
@@ -135,7 +137,7 @@ public void close() throws IOException {
 
         }
 
-        static class DeflateDecoderOutputStream extends OutputStream {
+        static final class DeflateDecoderOutputStream extends OutputStream {
 
             final DeflaterOutputStream deflaterOutputStream;
             Deflater deflater;
diff --git a/src/main/java/org/apache/commons/compress/archivers/zip/FileRandomAccessOutputStream.java b/src/main/java/org/apache/commons/compress/archivers/zip/FileRandomAccessOutputStream.java
index 48a14a6d3..6a0d69697 100644
--- a/src/main/java/org/apache/commons/compress/archivers/zip/FileRandomAccessOutputStream.java
+++ b/src/main/java/org/apache/commons/compress/archivers/zip/FileRandomAccessOutputStream.java
@@ -30,7 +30,7 @@
  * {@link RandomAccessOutputStream} implementation based on a file.
  */
 // Keep package-private; consider for Apache Commons IO.
-class FileRandomAccessOutputStream extends RandomAccessOutputStream {
+final class FileRandomAccessOutputStream extends RandomAccessOutputStream {
 
     private final FileChannel channel;
 
diff --git a/src/main/java/org/apache/commons/compress/archivers/zip/SeekableChannelRandomAccessOutputStream.java b/src/main/java/org/apache/commons/compress/archivers/zip/SeekableChannelRandomAccessOutputStream.java
index 0ebdc9489..30490ee8c 100644
--- a/src/main/java/org/apache/commons/compress/archivers/zip/SeekableChannelRandomAccessOutputStream.java
+++ b/src/main/java/org/apache/commons/compress/archivers/zip/SeekableChannelRandomAccessOutputStream.java
@@ -26,7 +26,7 @@
  * {@link RandomAccessOutputStream} implementation for SeekableByteChannel.
  */
 // Keep package-private; consider for Apache Commons IO.
-class SeekableChannelRandomAccessOutputStream extends RandomAccessOutputStream {
+final class SeekableChannelRandomAccessOutputStream extends RandomAccessOutputStream {
 
     private final SeekableByteChannel channel;
 
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 264f0a850..4425ecc0e 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
@@ -96,7 +96,7 @@ public class ZipFile implements Closeable {
      * Lock-free implementation of BoundedInputStream. The implementation uses positioned reads on the underlying archive file channel and therefore performs
      * significantly faster in concurrent environment.
      */
-    private static class BoundedFileChannelInputStream extends BoundedArchiveInputStream {
+    private static final class BoundedFileChannelInputStream extends BoundedArchiveInputStream {
         private final FileChannel archive;
 
         BoundedFileChannelInputStream(final long start, final long remaining, final FileChannel archive) {
diff --git a/src/main/java/org/apache/commons/compress/archivers/zip/ZipIoUtil.java b/src/main/java/org/apache/commons/compress/archivers/zip/ZipIoUtil.java
index 001446612..47ca263e7 100644
--- a/src/main/java/org/apache/commons/compress/archivers/zip/ZipIoUtil.java
+++ b/src/main/java/org/apache/commons/compress/archivers/zip/ZipIoUtil.java
@@ -27,7 +27,7 @@
  * IO utilities for Zip operations.
  */
 // Keep package-private; consider for Apache Commons IO.
-class ZipIoUtil {
+final class ZipIoUtil {
 
     /**
      * Writes full buffer to channel.
diff --git a/src/main/java/org/apache/commons/compress/harmony/pack200/Archive.java b/src/main/java/org/apache/commons/compress/harmony/pack200/Archive.java
index f2018049e..c2017bdc4 100644
--- a/src/main/java/org/apache/commons/compress/harmony/pack200/Archive.java
+++ b/src/main/java/org/apache/commons/compress/harmony/pack200/Archive.java
@@ -35,7 +35,7 @@
  */
 public class Archive {
 
-    static class PackingFile {
+    static final class PackingFile {
 
         private final String name;
         private byte[] contents;
@@ -89,7 +89,7 @@ public String toString() {
         }
     }
 
-    static class SegmentUnit {
+    static final class SegmentUnit {
 
         private final List<Pack200ClassReader> classList;
 
diff --git a/src/main/java/org/apache/commons/compress/harmony/pack200/IcBands.java b/src/main/java/org/apache/commons/compress/harmony/pack200/IcBands.java
index 2f42cb5ff..51acb34c9 100644
--- a/src/main/java/org/apache/commons/compress/harmony/pack200/IcBands.java
+++ b/src/main/java/org/apache/commons/compress/harmony/pack200/IcBands.java
@@ -33,7 +33,7 @@
  */
 public class IcBands extends BandSet {
 
-    static class IcTuple implements Comparable<IcTuple> {
+    static final class IcTuple implements Comparable<IcTuple> {
 
         protected CPClass C; // this class
         protected int F; // flags


(commons-compress) 03/04: Package-private class doesn't need Javadoc since tag

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 1461db54297df262c2d893a42ccf2df1f9fff0d2
Author: Gary Gregory <ga...@gmail.com>
AuthorDate: Wed Feb 5 08:09:43 2025 -0500

    Package-private class doesn't need Javadoc since tag
---
 .../java/org/apache/commons/compress/archivers/ArchiveInputStream.java  | 2 --
 1 file changed, 2 deletions(-)

diff --git a/src/main/java/org/apache/commons/compress/archivers/ArchiveInputStream.java b/src/main/java/org/apache/commons/compress/archivers/ArchiveInputStream.java
index 71af0e817..03b2cec78 100644
--- a/src/main/java/org/apache/commons/compress/archivers/ArchiveInputStream.java
+++ b/src/main/java/org/apache/commons/compress/archivers/ArchiveInputStream.java
@@ -53,8 +53,6 @@ public abstract class ArchiveInputStream<E extends ArchiveEntry> extends FilterI
 
     /**
      * An iterator over a collection of a specific {@link ArchiveEntry} type.
-     *
-     * @since 1.27.0
      */
     class ArchiveEntryIOIterator implements IOIterator<E> {
 


(commons-compress) 01/04: better comment

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 03fc17143caffcb5c1511f8b94b959beb1d78218
Author: Gary Gregory <ga...@gmail.com>
AuthorDate: Tue Feb 4 14:32:55 2025 -0500

    better comment
---
 .../apache/commons/compress/archivers/zip/ZipCompressMethodXzTest.java  | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/test/java/org/apache/commons/compress/archivers/zip/ZipCompressMethodXzTest.java b/src/test/java/org/apache/commons/compress/archivers/zip/ZipCompressMethodXzTest.java
index 9c125868d..e0f6bd1cf 100644
--- a/src/test/java/org/apache/commons/compress/archivers/zip/ZipCompressMethodXzTest.java
+++ b/src/test/java/org/apache/commons/compress/archivers/zip/ZipCompressMethodXzTest.java
@@ -60,7 +60,7 @@ private static void compress(final InputStream input, final OutputStream output)
 
     @Test
     public void testXzInputStream() throws IOException {
-        // test-method-xz.zip was created with:
+        // The file test-method-xz.zip was created with:
         // "\Program Files\7-Zip\7z.exe" a test-method-xz.zip -mm=xz LICENSE.txt
         // The "mm" option specifies the compress method
         final Path file = getPath("org/apache/commons/compress/zip/test-method-xz.zip");


(commons-compress) 02/04: Javadoc

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 4b148974a05d70605fb4e335b94d0ee860e59c11
Author: Gary Gregory <ga...@gmail.com>
AuthorDate: Wed Feb 5 07:36:20 2025 -0500

    Javadoc
---
 .../archivers/dump/DumpArchiveConstants.java       | 61 ++++++++++++++++++----
 .../compress/archivers/dump/DumpArchiveEntry.java  | 17 ++++--
 .../commons/compress/archivers/zip/BinaryTree.java |  2 +-
 .../compress/archivers/zip/PKWareExtraHeader.java  |  8 +--
 .../commons/compress/archivers/zip/ZipMethod.java  |  6 +--
 5 files changed, 72 insertions(+), 22 deletions(-)

diff --git a/src/main/java/org/apache/commons/compress/archivers/dump/DumpArchiveConstants.java b/src/main/java/org/apache/commons/compress/archivers/dump/DumpArchiveConstants.java
index ad1616493..dfeeee793 100644
--- a/src/main/java/org/apache/commons/compress/archivers/dump/DumpArchiveConstants.java
+++ b/src/main/java/org/apache/commons/compress/archivers/dump/DumpArchiveConstants.java
@@ -48,13 +48,18 @@ public enum COMPRESSION_TYPE {
          */
         LZO(2);
 
+        /**
+         * Finds the matching enumeration value for the given code.
+         *
+         * @param code a code.
+         * @return a value, never null.
+         */
         public static COMPRESSION_TYPE find(final int code) {
-            for (final COMPRESSION_TYPE t : values()) {
-                if (t.code == code) {
-                    return t;
+            for (final COMPRESSION_TYPE e : values()) {
+                if (e.code == code) {
+                    return e;
                 }
             }
-
             return UNKNOWN;
         }
 
@@ -100,13 +105,18 @@ public enum SEGMENT_TYPE {
          */
         CLRI(6);
 
+        /**
+         * Finds the matching enumeration value for the given code.
+         *
+         * @param code a code.
+         * @return a value, or null if not found.
+         */
         public static SEGMENT_TYPE find(final int code) {
-            for (final SEGMENT_TYPE t : values()) {
-                if (t.code == code) {
-                    return t;
+            for (final SEGMENT_TYPE e : values()) {
+                if (e.code == code) {
+                    return e;
                 }
             }
-
             return null;
         }
 
@@ -117,19 +127,52 @@ public static SEGMENT_TYPE find(final int code) {
         }
     }
 
+    /**
+     * TP_SIZE value {@value}.
+     */
     public static final int TP_SIZE = 1024;
+
+    /**
+     * NTREC value {@value}.
+     */
     public static final int NTREC = 10;
+
+    /**
+     * HIGH_DENSITY_NTREC value {@value}.
+     */
     public static final int HIGH_DENSITY_NTREC = 32;
+
+    /**
+     * OFS_MAGIC value {@value}.
+     */
     public static final int OFS_MAGIC = 60011;
+
+    /**
+     * NFS_MAGIC value {@value}.
+     */
     public static final int NFS_MAGIC = 60012;
+
+    /**
+     * FS_UFS2_MAGIC value {@value}.
+     */
     public static final int FS_UFS2_MAGIC = 0x19540119;
+
+    /**
+     * CHECKSUM value {@value}.
+     */
     public static final int CHECKSUM = 84446;
 
+    /**
+     * LBLSIZE value {@value}.
+     */
     public static final int LBLSIZE = 16;
 
+    /**
+     * NAMELEN value {@value}.
+     */
     public static final int NAMELEN = 64;
 
-    /* do not instantiate */
+    /** Do not instantiate. */
     private DumpArchiveConstants() {
     }
 }
diff --git a/src/main/java/org/apache/commons/compress/archivers/dump/DumpArchiveEntry.java b/src/main/java/org/apache/commons/compress/archivers/dump/DumpArchiveEntry.java
index 9e0d6319c..0af0681a6 100644
--- a/src/main/java/org/apache/commons/compress/archivers/dump/DumpArchiveEntry.java
+++ b/src/main/java/org/apache/commons/compress/archivers/dump/DumpArchiveEntry.java
@@ -239,19 +239,22 @@ public enum PERMISSION {
          */
         WORLD_EXEC(00001);
 
+        /**
+         * Finds a matching set of enumeration values for the given code.
+         *
+         * @param code a code.
+         * @return a Set of values, never null.
+         */
         public static Set<PERMISSION> find(final int code) {
             final Set<PERMISSION> set = new HashSet<>();
-
             for (final PERMISSION p : values()) {
                 if ((code & p.code) == p.code) {
                     set.add(p);
                 }
             }
-
             if (set.isEmpty()) {
                 return Collections.emptySet();
             }
-
             return EnumSet.copyOf(set);
         }
 
@@ -352,15 +355,19 @@ public enum TYPE {
          */
         UNKNOWN(15);
 
+        /**
+         * Finds a matching enumeration value for the given code.
+         *
+         * @param code a code.
+         * @return a value, never null.
+         */
         public static TYPE find(final int code) {
             TYPE type = UNKNOWN;
-
             for (final TYPE t : values()) {
                 if (code == t.code) {
                     type = t;
                 }
             }
-
             return type;
         }
 
diff --git a/src/main/java/org/apache/commons/compress/archivers/zip/BinaryTree.java b/src/main/java/org/apache/commons/compress/archivers/zip/BinaryTree.java
index 4c8e42696..0c8e24932 100644
--- a/src/main/java/org/apache/commons/compress/archivers/zip/BinaryTree.java
+++ b/src/main/java/org/apache/commons/compress/archivers/zip/BinaryTree.java
@@ -171,7 +171,7 @@ public void addLeaf(final int node, final int path, final int depth, final int v
     /**
      * Reads a value from the specified bit stream.
      *
-     * @param stream
+     * @param stream The data source.
      * @return the value decoded, or -1 if the end of the stream is reached
      * @throws IOException on error.
      */
diff --git a/src/main/java/org/apache/commons/compress/archivers/zip/PKWareExtraHeader.java b/src/main/java/org/apache/commons/compress/archivers/zip/PKWareExtraHeader.java
index 478cb8956..f78186039 100644
--- a/src/main/java/org/apache/commons/compress/archivers/zip/PKWareExtraHeader.java
+++ b/src/main/java/org/apache/commons/compress/archivers/zip/PKWareExtraHeader.java
@@ -146,14 +146,14 @@ public static EncryptionAlgorithm getAlgorithmByCode(final int code) {
         private final int code;
 
         /**
-         * private constructor for enum style class.
+         * Constructs a new instance.
          */
         EncryptionAlgorithm(final int code) {
             this.code = code;
         }
 
         /**
-         * the algorithm id.
+         * Gets the algorithm ID.
          *
          * @return the PKWare AlgorithmId
          */
@@ -232,14 +232,14 @@ public static HashAlgorithm getAlgorithmByCode(final int code) {
         private final int code;
 
         /**
-         * private constructor for enum style class.
+         * Constructs a new instance.
          */
         HashAlgorithm(final int code) {
             this.code = code;
         }
 
         /**
-         * the hash algorithm ID.
+         * Gets the hash algorithm ID.
          *
          * @return the PKWare hashAlg
          */
diff --git a/src/main/java/org/apache/commons/compress/archivers/zip/ZipMethod.java b/src/main/java/org/apache/commons/compress/archivers/zip/ZipMethod.java
index 4176f6b3e..d0fe18081 100644
--- a/src/main/java/org/apache/commons/compress/archivers/zip/ZipMethod.java
+++ b/src/main/java/org/apache/commons/compress/archivers/zip/ZipMethod.java
@@ -196,7 +196,7 @@ public enum ZipMethod {
             .unmodifiableMap(Stream.of(values()).collect(Collectors.toMap(ZipMethod::getCode, Function.identity())));
 
     /**
-     * returns the {@link ZipMethod} for the given code or null if the method is not known.
+     * Gets the {@link ZipMethod} for the given code or null if the method is not known.
      *
      * @param code the code
      * @return the {@link ZipMethod} for the given code or null if the method is not known.
@@ -222,14 +222,14 @@ static boolean isZstd(final int method) {
     }
 
     /**
-     * private constructor for enum style class.
+     * Constructs a new instance.
      */
     ZipMethod(final int code) {
         this.code = code;
     }
 
     /**
-     * the code of the compression method.
+     * Gets the code of the compression method.
      *
      * @see ZipArchiveEntry#getMethod()
      * @return an integer code for the method