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/08/10 15:02:18 UTC

(commons-compress) branch master updated (33808590b -> ae32f7565)

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 33808590b Add org.apache.commons.compress.archivers.zip.ZipArchiveInputStreamTest.testDecompressNextSymbol()
     new 62c75277c Uppercase constant
     new 57e708358 Internal refactoring for FLG header constants
     new fc409b152 Javadoc
     new 108ebf307 Comment
     new ae32f7565 Internal refactoring for XFL header constants

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:
 .../commons/compress/compressors/gzip/FLG.java     | 95 ++++++++++++++++++++++
 .../gzip/GzipCompressorInputStream.java            | 14 ++--
 .../gzip/GzipCompressorOutputStream.java           | 14 ++--
 .../compress/compressors/gzip/GzipUtils.java       | 87 +++++++-------------
 .../commons/compress/compressors/gzip/XFL.java     | 59 ++++++++++++++
 5 files changed, 196 insertions(+), 73 deletions(-)
 create mode 100644 src/main/java/org/apache/commons/compress/compressors/gzip/FLG.java
 create mode 100644 src/main/java/org/apache/commons/compress/compressors/gzip/XFL.java


(commons-compress) 04/05: 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 108ebf307e888bf040942bf5c32c57841814295e
Author: Gary D. Gregory <ga...@gmail.com>
AuthorDate: Sun Aug 10 11:00:11 2025 -0400

    Comment
---
 src/main/java/org/apache/commons/compress/compressors/gzip/FLG.java | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/main/java/org/apache/commons/compress/compressors/gzip/FLG.java b/src/main/java/org/apache/commons/compress/compressors/gzip/FLG.java
index 573c0f0f7..3782004ce 100644
--- a/src/main/java/org/apache/commons/compress/compressors/gzip/FLG.java
+++ b/src/main/java/org/apache/commons/compress/compressors/gzip/FLG.java
@@ -90,6 +90,6 @@ final class FLG {
     static final int FRESERVED = 0xE0;
 
     private FLG() {
-        // no instance.
+        // No instance.
     }
 }


(commons-compress) 02/05: Internal refactoring for FLG header constants

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 57e708358976af517a4c40cb0e3f1eb0b3dff86c
Author: Gary D. Gregory <ga...@gmail.com>
AuthorDate: Sun Aug 10 10:51:43 2025 -0400

    Internal refactoring for FLG header constants
---
 .../commons/compress/compressors/gzip/FLG.java     | 83 ++++++++++++++++++++++
 .../gzip/GzipCompressorInputStream.java            | 10 +--
 .../gzip/GzipCompressorOutputStream.java           |  8 +--
 .../compress/compressors/gzip/GzipUtils.java       | 58 ++++++---------
 4 files changed, 114 insertions(+), 45 deletions(-)

diff --git a/src/main/java/org/apache/commons/compress/compressors/gzip/FLG.java b/src/main/java/org/apache/commons/compress/compressors/gzip/FLG.java
new file mode 100644
index 000000000..8bd5c38c0
--- /dev/null
+++ b/src/main/java/org/apache/commons/compress/compressors/gzip/FLG.java
@@ -0,0 +1,83 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   https://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.commons.compress.compressors.gzip;
+
+/**
+ * Declares constants for the header {@code FLG} (FLaGs) byte from <a href="https://datatracker.ietf.org/doc/html/rfc1952">RFC 1952 GZIP File Format
+ * Specification May 1996</a> section 2.3.1. Member header and trailer.
+ * <p>
+ * The {@code FLG} (FLaGs) byte is divided into individual bits as follows:
+ * </p>
+ *
+ * <pre>
+ * FLG (FLaGs)
+ *
+ *     bit 0   FTEXT
+ *     bit 1   FHCRC
+ *     bit 2   FEXTRA
+ *     bit 3   FNAME
+ *     bit 4   FCOMMENT
+ *     bit 5   reserved
+ *     bit 6   reserved
+ *     bit 7   reserved
+ * </pre>
+ */
+final class FLG {
+
+    /**
+     * Header flag indicating a comment follows the header.
+     * <p>
+     * If set, a zero-terminated file comment is present, not interpreted, and only intended for human consumption. The comment must contain ISO 8859-1
+     * (LATIN-1) characters. Line breaks should be encoded as a single line feed character (10 decimal).
+     * </p>
+     */
+    static final int FCOMMENT = 0x10;
+
+    /**
+     * Header flag indicating an EXTRA subfields collection follows the header.
+     */
+    static final int FEXTRA = 0x04;
+
+    /**
+     * Header flag indicating a header CRC follows the header.
+     * <p>
+     * If FHCRC is set, then a CRC16 for the gzip header is present, immediately before the compressed data. The CRC16 consists of the two least significant
+     * bytes of the CRC32 for all bytes of the gzip header up to and not including the CRC16.
+     * </p>
+     * <p>
+     * The FHCRC bit was never set by versions of gzip up to 1.2.4, even though it was documented with a different meaning in gzip 1.2.4.
+     * </p>
+     */
+    static final int FHCRC = 0x02;
+
+    /**
+     * Header flag indicating a file name follows the header.
+     */
+    static final int FNAME = 0x08;
+
+    /**
+     * Reserved {@code FLG} bits must be zero.
+     */
+    static final int FRESERVED = 0xE0;
+
+    private FLG() {
+        // no instance.
+    }
+}
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 26b4826e2..8110cddb6 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
@@ -383,7 +383,7 @@ private boolean init(final boolean isFirstMember) throws IOException {
             throw new CompressorException("Unsupported compression method %d in the .gz header", method);
         }
         final int flg = inData.readUnsignedByte();
-        if ((flg & GzipUtils.FRESERVED) != 0) {
+        if ((flg & FLG.FRESERVED) != 0) {
             throw new CompressorException("Reserved flags are set in the .gz header.");
         }
         parameters.setModificationTime(ByteUtils.fromLittleEndian(inData, 4));
@@ -400,7 +400,7 @@ private boolean init(final boolean isFirstMember) throws IOException {
         }
         parameters.setOperatingSystem(inData.readUnsignedByte());
         // Extra field
-        if ((flg & GzipUtils.FEXTRA) != 0) {
+        if ((flg & FLG.FEXTRA) != 0) {
             int xlen = inData.readUnsignedByte();
             xlen |= inData.readUnsignedByte() << 8;
             parameters.setExtraFieldXlen(xlen);
@@ -412,11 +412,11 @@ private boolean init(final boolean isFirstMember) throws IOException {
             }
         }
         // Original file name
-        if ((flg & GzipUtils.FNAME) != 0) {
+        if ((flg & FLG.FNAME) != 0) {
             parameters.setFileName(new String(readToNull(inData), parameters.getFileNameCharset()));
         }
         // Comment
-        if ((flg & GzipUtils.FCOMMENT) != 0) {
+        if ((flg & FLG.FCOMMENT) != 0) {
             parameters.setComment(new String(readToNull(inData), parameters.getFileNameCharset()));
         }
         // Header "CRC16" which is actually a truncated CRC32 (which isn't
@@ -424,7 +424,7 @@ private boolean init(final boolean isFirstMember) throws IOException {
         // sets this, so it's not worth trying to verify it. GNU gzip 1.4
         // doesn't support this field, but zlib seems to be able to at least
         // skip over it.
-        if ((flg & GzipUtils.FHCRC) != 0) {
+        if ((flg & FLG.FHCRC) != 0) {
             parameters.setHeaderCRC(true);
             inData.readShort();
         }
diff --git a/src/main/java/org/apache/commons/compress/compressors/gzip/GzipCompressorOutputStream.java b/src/main/java/org/apache/commons/compress/compressors/gzip/GzipCompressorOutputStream.java
index 7b958448f..220548fc3 100644
--- a/src/main/java/org/apache/commons/compress/compressors/gzip/GzipCompressorOutputStream.java
+++ b/src/main/java/org/apache/commons/compress/compressors/gzip/GzipCompressorOutputStream.java
@@ -171,10 +171,10 @@ private void writeMemberHeader(final GzipParameters parameters) throws IOExcepti
         buffer.put((byte) GzipUtils.ID1);
         buffer.put((byte) GzipUtils.ID2);
         buffer.put((byte) Deflater.DEFLATED); // compression method (8: deflate)
-        buffer.put((byte) ((extra != null ? GzipUtils.FEXTRA : 0)
-                | (fileName != null ? GzipUtils.FNAME : 0)
-                | (comment != null ? GzipUtils.FCOMMENT : 0)
-                | (parameters.getHeaderCRC() ? GzipUtils.FHCRC : 0)
+        buffer.put((byte) ((extra != null ? FLG.FEXTRA : 0)
+                | (fileName != null ? FLG.FNAME : 0)
+                | (comment != null ? FLG.FCOMMENT : 0)
+                | (parameters.getHeaderCRC() ? FLG.FHCRC : 0)
         )); // flags
         buffer.putInt((int) parameters.getModificationInstant().getEpochSecond());
         // extra flags
diff --git a/src/main/java/org/apache/commons/compress/compressors/gzip/GzipUtils.java b/src/main/java/org/apache/commons/compress/compressors/gzip/GzipUtils.java
index 502ff0e60..c0351c219 100644
--- a/src/main/java/org/apache/commons/compress/compressors/gzip/GzipUtils.java
+++ b/src/main/java/org/apache/commons/compress/compressors/gzip/GzipUtils.java
@@ -27,27 +27,17 @@
 
 /**
  * Utility code for the GZIP compression format.
- *
  * @see <a href="https://datatracker.ietf.org/doc/html/rfc1952">RFC 1952 GZIP File Format Specification</a>
+ *
  * @ThreadSafe
  */
 public class GzipUtils {
 
-    /** Header flag indicating a comment follows the header. */
-    static final int FCOMMENT = 0x10;
-
-    /** Header flag indicating an EXTRA subfields collection follows the header. */
-    static final int FEXTRA = 0x04;
-
-    /** Header flag indicating a header CRC follows the header. */
-    static final int FHCRC = 0x02;
-
-    private static final FileNameUtil FNU_INSTANCE;
-
-    /** Header flag indicating a file name follows the header. */
-    static final int FNAME = 0x08;
-
-    static final int FRESERVED = 0xE0;
+    /**
+     * Using {@link LinkedHashMap} so {@code .tgz} is preferred over {@code .taz} as compressed extension of {@code .tar} as FileNameUtil will use the first one
+     * found.
+     */
+    private static final FileNameUtil FNU_INSTANCE = new FileNameUtil(uncompressSuffix(), ".gz");
 
     /**
      * Charset for file name and comments per the <a href="https://tools.ietf.org/html/rfc1952">GZIP File Format Specification</a>.
@@ -85,25 +75,6 @@ public class GzipUtils {
 
     static final byte XFL_UNKNOWN = 0;
 
-    /**
-     * Using {@link LinkedHashMap} so {@code .tgz} is preferred over {@code .taz} as compressed extension of {@code .tar} as FileNameUtil will use the first one
-     * found.
-     */
-    static {
-        final Map<String, String> uncompressSuffix = new LinkedHashMap<>();
-        uncompressSuffix.put(".tgz", ".tar");
-        uncompressSuffix.put(".taz", ".tar");
-        uncompressSuffix.put(".svgz", ".svg");
-        uncompressSuffix.put(".cpgz", ".cpio");
-        uncompressSuffix.put(".wmz", ".wmf");
-        uncompressSuffix.put(".emz", ".emf");
-        uncompressSuffix.put(".gz", "");
-        uncompressSuffix.put(".z", "");
-        uncompressSuffix.put("-gz", "");
-        uncompressSuffix.put("-z", "");
-        uncompressSuffix.put("_z", "");
-        FNU_INSTANCE = new FileNameUtil(uncompressSuffix, ".gz");
-    }
     /**
      * Maps the given file name to the name that the file should have after compression with gzip. Common file types with custom suffixes for compressed
      * versions are automatically detected and correctly mapped. For example the name "package.tar" is mapped to "package.tgz". If no custom mapping is
@@ -117,7 +88,6 @@ public class GzipUtils {
     public static String getCompressedFilename(final String fileName) {
         return FNU_INSTANCE.getCompressedFileName(fileName);
     }
-
     /**
      * Maps the given file name to the name that the file should have after compression with gzip. Common file types with custom suffixes for compressed
      * versions are automatically detected and correctly mapped. For example the name "package.tar" is mapped to "package.tgz". If no custom mapping is
@@ -183,6 +153,22 @@ public static boolean isCompressedFileName(final String fileName) {
         return FNU_INSTANCE.isCompressedFileName(fileName);
     }
 
+    private static Map<String, String> uncompressSuffix() {
+        final Map<String, String> uncompressSuffix = new LinkedHashMap<>();
+        uncompressSuffix.put(".tgz", ".tar");
+        uncompressSuffix.put(".taz", ".tar");
+        uncompressSuffix.put(".svgz", ".svg");
+        uncompressSuffix.put(".cpgz", ".cpio");
+        uncompressSuffix.put(".wmz", ".wmf");
+        uncompressSuffix.put(".emz", ".emf");
+        uncompressSuffix.put(".gz", "");
+        uncompressSuffix.put(".z", "");
+        uncompressSuffix.put("-gz", "");
+        uncompressSuffix.put("-z", "");
+        uncompressSuffix.put("_z", "");
+        return uncompressSuffix;
+    }
+
     /** Private constructor to prevent instantiation of this utility class. */
     private GzipUtils() {
     }


(commons-compress) 03/05: 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 fc409b152e64f3122ff5afed8f633a7ed0bfea66
Author: Gary D. Gregory <ga...@gmail.com>
AuthorDate: Sun Aug 10 10:58:31 2025 -0400

    Javadoc
---
 .../apache/commons/compress/compressors/gzip/FLG.java    | 16 ++++++++++++++--
 1 file changed, 14 insertions(+), 2 deletions(-)

diff --git a/src/main/java/org/apache/commons/compress/compressors/gzip/FLG.java b/src/main/java/org/apache/commons/compress/compressors/gzip/FLG.java
index 8bd5c38c0..573c0f0f7 100644
--- a/src/main/java/org/apache/commons/compress/compressors/gzip/FLG.java
+++ b/src/main/java/org/apache/commons/compress/compressors/gzip/FLG.java
@@ -20,8 +20,8 @@
 package org.apache.commons.compress.compressors.gzip;
 
 /**
- * Declares constants for the header {@code FLG} (FLaGs) byte from <a href="https://datatracker.ietf.org/doc/html/rfc1952">RFC 1952 GZIP File Format
- * Specification May 1996</a> section 2.3.1. Member header and trailer.
+ * Declares constants for the header {@code FLG} (FLaGs) byte from <a href="https://datatracker.ietf.org/doc/html/rfc1952#section-2.3.1">RFC 1952 GZIP File
+ * Format Specification May 1996</a> section 2.3.1. Member header and trailer.
  * <p>
  * The {@code FLG} (FLaGs) byte is divided into individual bits as follows:
  * </p>
@@ -38,6 +38,8 @@
  *     bit 6   reserved
  *     bit 7   reserved
  * </pre>
+ *
+ * @see <a href="https://datatracker.ietf.org/doc/html/rfc1952#section-2.3.1">RFC 1952 GZIP File Format Specification section 2.3.1</a>
  */
 final class FLG {
 
@@ -47,11 +49,15 @@ final class FLG {
      * If set, a zero-terminated file comment is present, not interpreted, and only intended for human consumption. The comment must contain ISO 8859-1
      * (LATIN-1) characters. Line breaks should be encoded as a single line feed character (10 decimal).
      * </p>
+     *
+     * @see <a href="https://datatracker.ietf.org/doc/html/rfc1952#section-2.3.1">RFC 1952 GZIP File Format Specification section 2.3.1</a>
      */
     static final int FCOMMENT = 0x10;
 
     /**
      * Header flag indicating an EXTRA subfields collection follows the header.
+     *
+     * @see <a href="https://datatracker.ietf.org/doc/html/rfc1952#section-2.3.1">RFC 1952 GZIP File Format Specification section 2.3.1</a>
      */
     static final int FEXTRA = 0x04;
 
@@ -64,16 +70,22 @@ final class FLG {
      * <p>
      * The FHCRC bit was never set by versions of gzip up to 1.2.4, even though it was documented with a different meaning in gzip 1.2.4.
      * </p>
+     *
+     * @see <a href="https://datatracker.ietf.org/doc/html/rfc1952#section-2.3.1">RFC 1952 GZIP File Format Specification section 2.3.1</a>
      */
     static final int FHCRC = 0x02;
 
     /**
      * Header flag indicating a file name follows the header.
+     *
+     * @see <a href="https://datatracker.ietf.org/doc/html/rfc1952#section-2.3.1">RFC 1952 GZIP File Format Specification section 2.3.1</a>
      */
     static final int FNAME = 0x08;
 
     /**
      * Reserved {@code FLG} bits must be zero.
+     *
+     * @see <a href="https://datatracker.ietf.org/doc/html/rfc1952#section-2.3.1">RFC 1952 GZIP File Format Specification section 2.3.1</a>
      */
     static final int FRESERVED = 0xE0;
 


(commons-compress) 01/05: Uppercase constant

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 62c75277cc44e14b56bff2fa7c1352f41c64c484
Author: Gary D. Gregory <ga...@gmail.com>
AuthorDate: Sun Aug 10 10:30:38 2025 -0400

    Uppercase constant
---
 .../commons/compress/compressors/gzip/GzipUtils.java     | 16 ++++++++--------
 1 file changed, 8 insertions(+), 8 deletions(-)

diff --git a/src/main/java/org/apache/commons/compress/compressors/gzip/GzipUtils.java b/src/main/java/org/apache/commons/compress/compressors/gzip/GzipUtils.java
index a1713b015..502ff0e60 100644
--- a/src/main/java/org/apache/commons/compress/compressors/gzip/GzipUtils.java
+++ b/src/main/java/org/apache/commons/compress/compressors/gzip/GzipUtils.java
@@ -42,7 +42,7 @@ public class GzipUtils {
     /** Header flag indicating a header CRC follows the header. */
     static final int FHCRC = 0x02;
 
-    private static final FileNameUtil fileNameUtil;
+    private static final FileNameUtil FNU_INSTANCE;
 
     /** Header flag indicating a file name follows the header. */
     static final int FNAME = 0x08;
@@ -102,7 +102,7 @@ public class GzipUtils {
         uncompressSuffix.put("-gz", "");
         uncompressSuffix.put("-z", "");
         uncompressSuffix.put("_z", "");
-        fileNameUtil = new FileNameUtil(uncompressSuffix, ".gz");
+        FNU_INSTANCE = new FileNameUtil(uncompressSuffix, ".gz");
     }
     /**
      * Maps the given file name to the name that the file should have after compression with gzip. Common file types with custom suffixes for compressed
@@ -115,7 +115,7 @@ public class GzipUtils {
      */
     @Deprecated
     public static String getCompressedFilename(final String fileName) {
-        return fileNameUtil.getCompressedFileName(fileName);
+        return FNU_INSTANCE.getCompressedFileName(fileName);
     }
 
     /**
@@ -128,7 +128,7 @@ public static String getCompressedFilename(final String fileName) {
      * @since 1.25.0
      */
     public static String getCompressedFileName(final String fileName) {
-        return fileNameUtil.getCompressedFileName(fileName);
+        return FNU_INSTANCE.getCompressedFileName(fileName);
     }
 
     /**
@@ -143,7 +143,7 @@ public static String getCompressedFileName(final String fileName) {
      */
     @Deprecated
     public static String getUncompressedFilename(final String fileName) {
-        return fileNameUtil.getUncompressedFileName(fileName);
+        return FNU_INSTANCE.getUncompressedFileName(fileName);
     }
 
     /**
@@ -157,7 +157,7 @@ public static String getUncompressedFilename(final String fileName) {
      * @since 1.25.0
      */
     public static String getUncompressedFileName(final String fileName) {
-        return fileNameUtil.getUncompressedFileName(fileName);
+        return FNU_INSTANCE.getUncompressedFileName(fileName);
     }
 
     /**
@@ -169,7 +169,7 @@ public static String getUncompressedFileName(final String fileName) {
      */
     @Deprecated
     public static boolean isCompressedFilename(final String fileName) {
-        return fileNameUtil.isCompressedFileName(fileName);
+        return FNU_INSTANCE.isCompressedFileName(fileName);
     }
 
     /**
@@ -180,7 +180,7 @@ public static boolean isCompressedFilename(final String fileName) {
      * @since 1.25.0
      */
     public static boolean isCompressedFileName(final String fileName) {
-        return fileNameUtil.isCompressedFileName(fileName);
+        return FNU_INSTANCE.isCompressedFileName(fileName);
     }
 
     /** Private constructor to prevent instantiation of this utility class. */


(commons-compress) 05/05: Internal refactoring for XFL header constants

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 ae32f75652177c66652678b136ef67c885629630
Author: Gary D. Gregory <ga...@gmail.com>
AuthorDate: Sun Aug 10 11:02:12 2025 -0400

    Internal refactoring for XFL header constants
---
 .../gzip/GzipCompressorInputStream.java            |  4 +-
 .../gzip/GzipCompressorOutputStream.java           |  6 +--
 .../compress/compressors/gzip/GzipUtils.java       | 17 -------
 .../commons/compress/compressors/gzip/XFL.java     | 59 ++++++++++++++++++++++
 4 files changed, 64 insertions(+), 22 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 8110cddb6..db4ae11df 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
@@ -388,10 +388,10 @@ private boolean init(final boolean isFirstMember) throws IOException {
         }
         parameters.setModificationTime(ByteUtils.fromLittleEndian(inData, 4));
         switch (inData.readUnsignedByte()) { // extra flags
-        case GzipUtils.XFL_MAX_COMPRESSION:
+        case XFL.MAX_COMPRESSION:
             parameters.setCompressionLevel(Deflater.BEST_COMPRESSION);
             break;
-        case GzipUtils.XFL_MAX_SPEED:
+        case XFL.MAX_SPEED:
             parameters.setCompressionLevel(Deflater.BEST_SPEED);
             break;
         default:
diff --git a/src/main/java/org/apache/commons/compress/compressors/gzip/GzipCompressorOutputStream.java b/src/main/java/org/apache/commons/compress/compressors/gzip/GzipCompressorOutputStream.java
index 220548fc3..3d4c519bd 100644
--- a/src/main/java/org/apache/commons/compress/compressors/gzip/GzipCompressorOutputStream.java
+++ b/src/main/java/org/apache/commons/compress/compressors/gzip/GzipCompressorOutputStream.java
@@ -180,11 +180,11 @@ private void writeMemberHeader(final GzipParameters parameters) throws IOExcepti
         // extra flags
         final int compressionLevel = parameters.getCompressionLevel();
         if (compressionLevel == Deflater.BEST_COMPRESSION) {
-            buffer.put(GzipUtils.XFL_MAX_COMPRESSION);
+            buffer.put(XFL.MAX_COMPRESSION);
         } else if (compressionLevel == Deflater.BEST_SPEED) {
-            buffer.put(GzipUtils.XFL_MAX_SPEED);
+            buffer.put(XFL.MAX_SPEED);
         } else {
-            buffer.put(GzipUtils.XFL_UNKNOWN);
+            buffer.put(XFL.UNKNOWN);
         }
         buffer.put((byte) parameters.getOperatingSystem());
         out.write(buffer.array());
diff --git a/src/main/java/org/apache/commons/compress/compressors/gzip/GzipUtils.java b/src/main/java/org/apache/commons/compress/compressors/gzip/GzipUtils.java
index c0351c219..35846e074 100644
--- a/src/main/java/org/apache/commons/compress/compressors/gzip/GzipUtils.java
+++ b/src/main/java/org/apache/commons/compress/compressors/gzip/GzipUtils.java
@@ -58,23 +58,6 @@ public class GzipUtils {
      */
     static final int ID2 = 139;
 
-    /**
-     * Member header XFL (eXtra FLags) when the "deflate" method (CM = 8) is set, then XFL = 2 means the compressor used maximum compression (slowest
-     * algorithm).
-     *
-     * See <a href="https://datatracker.ietf.org/doc/html/rfc1952#page-5">RFC1952</a> 2.3.1. Member header and trailer.
-     */
-    static final byte XFL_MAX_COMPRESSION = 2;
-
-    /**
-     * Member header XFL (eXtra FLags) when the "deflate" method (CM = 8) is set, then XFL = 4 means the compressor used the fastest algorithm.
-     *
-     * See <a href="https://datatracker.ietf.org/doc/html/rfc1952#page-5">RFC1952</a> 2.3.1. Member header and trailer.
-     */
-    static final byte XFL_MAX_SPEED = 4;
-
-    static final byte XFL_UNKNOWN = 0;
-
     /**
      * Maps the given file name to the name that the file should have after compression with gzip. Common file types with custom suffixes for compressed
      * versions are automatically detected and correctly mapped. For example the name "package.tar" is mapped to "package.tgz". If no custom mapping is
diff --git a/src/main/java/org/apache/commons/compress/compressors/gzip/XFL.java b/src/main/java/org/apache/commons/compress/compressors/gzip/XFL.java
new file mode 100644
index 000000000..b815b5803
--- /dev/null
+++ b/src/main/java/org/apache/commons/compress/compressors/gzip/XFL.java
@@ -0,0 +1,59 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   https://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.commons.compress.compressors.gzip;
+
+/**
+ * Declares constants for the header {@code XFL} (eXtra FLags) byte from <a href="https://datatracker.ietf.org/doc/html/rfc1952#section-2.3.1">RFC 1952 GZIP
+ * File Format Specification May 1996</a> section 2.3.1. Member header and trailer.
+ * <p>
+ * These flags are available for use by specific compression methods. The "deflate" method (CM = 8) sets these flags as follows:
+ * </p>
+ *
+ * <pre>
+ *   XFL = 2 - compressor used maximum compression,
+ *             slowest algorithm
+ *   XFL = 4 - compressor used fastest algorithm
+ * </pre>
+ *
+ * @see <a href="https://datatracker.ietf.org/doc/html/rfc1952#section-2.3.1">RFC 1952 GZIP File Format Specification section 2.3.1</a>
+ */
+final class XFL {
+
+    /**
+     * Member header XFL (eXtra FLags) when the "deflate" method (CM = 8) is set, then XFL = 2 means the compressor used maximum compression (slowest
+     * algorithm).
+     *
+     * @see <a href="https://datatracker.ietf.org/doc/html/rfc1952#section-2.3.1">RFC 1952 GZIP File Format Specification section 2.3.1</a>
+     */
+    static final byte MAX_COMPRESSION = 2;
+
+    /**
+     * Member header XFL (eXtra FLags) when the "deflate" method (CM = 8) is set, then XFL = 4 means the compressor used the fastest algorithm.
+     *
+     * @see <a href="https://datatracker.ietf.org/doc/html/rfc1952#section-2.3.1">RFC 1952 GZIP File Format Specification section 2.3.1</a>
+     */
+    static final byte MAX_SPEED = 4;
+
+    static final byte UNKNOWN = 0;
+
+    private XFL() {
+        // No instances.
+    }
+}