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 2023/01/10 03:36:18 UTC

[commons-compress] branch master updated (cf8a288f -> 279ebf0f)

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 cf8a288f Bump actions/checkout from 3.2.0 to 3.3.0
     new faa8b444 Refactor and comment
     new 279ebf0f Format

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:
 .../compressors/gzip/GzipCompressorInputStream.java        |  6 ++----
 .../compressors/gzip/GzipCompressorOutputStream.java       |  6 ++----
 .../commons/compress/compressors/gzip/GzipUtils.java       |  7 +++++++
 .../java/org/apache/commons/compress/AbstractTestCase.java | 14 ++++++++------
 4 files changed, 19 insertions(+), 14 deletions(-)


[commons-compress] 02/02: Format

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 279ebf0f8a0470e46975d2212160e82e2194b88e
Author: Gary Gregory <ga...@gmail.com>
AuthorDate: Mon Jan 9 22:36:11 2023 -0500

    Format
---
 .../java/org/apache/commons/compress/AbstractTestCase.java | 14 ++++++++------
 1 file changed, 8 insertions(+), 6 deletions(-)

diff --git a/src/test/java/org/apache/commons/compress/AbstractTestCase.java b/src/test/java/org/apache/commons/compress/AbstractTestCase.java
index 593a484d..719920c8 100644
--- a/src/test/java/org/apache/commons/compress/AbstractTestCase.java
+++ b/src/test/java/org/apache/commons/compress/AbstractTestCase.java
@@ -49,6 +49,7 @@ public abstract class AbstractTestCase {
     protected interface StreamWrapper<I extends InputStream> {
         I wrap(InputStream in) throws Exception;
     }
+
     private static final boolean ON_WINDOWS =
             System.getProperty("os.name").toLowerCase(Locale.ENGLISH).contains("windows");
 
@@ -65,6 +66,7 @@ public abstract class AbstractTestCase {
         }
         return new File(uri);
     }
+
     public static Path getPath(final String path) throws IOException {
         return getFile(path).toPath();
     }
@@ -78,18 +80,18 @@ public abstract class AbstractTestCase {
         if (s != null) {
             for (final String element : s) {
                 final File file = new File(f, element);
-                if (file.isDirectory()){
+                if (file.isDirectory()) {
                     rmdir(file);
                 }
                 final boolean ok = tryHardToDelete(file);
-                if (!ok && file.exists()){
-                    System.out.println("Failed to delete "+element+" in "+f.getPath());
+                if (!ok && file.exists()) {
+                    System.out.println("Failed to delete " + element + " in " + f.getPath());
                 }
             }
         }
         tryHardToDelete(f); // safer to delete and check
-        if (f.exists()){
-            throw new Error("Failed to delete "+f.getPath());
+        if (f.exists()) {
+            throw new Error("Failed to delete " + f.getPath());
         }
     }
 
@@ -401,7 +403,7 @@ public abstract class AbstractTestCase {
         dir = resultDir = null;
         if (!tryHardToDelete(archive)) {
             // Note: this exception won't be shown if the test has already failed
-            throw new Exception("Could not delete "+archive.getPath());
+            throw new Exception("Could not delete " + archive.getPath());
         }
     }
 }


[commons-compress] 01/02: Refactor and 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 faa8b444f6e67afe8552262d7576e55e8c5eb4bc
Author: Gary Gregory <ga...@gmail.com>
AuthorDate: Mon Jan 9 22:35:31 2023 -0500

    Refactor and comment
---
 .../compress/compressors/gzip/GzipCompressorInputStream.java       | 6 ++----
 .../compress/compressors/gzip/GzipCompressorOutputStream.java      | 6 ++----
 .../org/apache/commons/compress/compressors/gzip/GzipUtils.java    | 7 +++++++
 3 files changed, 11 insertions(+), 8 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 63ae8e3f..f75e78c8 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
@@ -18,8 +18,6 @@
  */
 package org.apache.commons.compress.compressors.gzip;
 
-import static java.nio.charset.StandardCharsets.ISO_8859_1;
-
 import java.io.BufferedInputStream;
 import java.io.ByteArrayOutputStream;
 import java.io.DataInput;
@@ -287,12 +285,12 @@ public class GzipCompressorInputStream extends CompressorInputStream
 
         // Original file name
         if ((flg & FNAME) != 0) {
-            parameters.setFilename(new String(readToNull(inData), ISO_8859_1));
+            parameters.setFilename(new String(readToNull(inData), GzipUtils.GZIP_ENCODING));
         }
 
         // Comment
         if ((flg & FCOMMENT) != 0) {
-            parameters.setComment(new String(readToNull(inData), ISO_8859_1));
+            parameters.setComment(new String(readToNull(inData), GzipUtils.GZIP_ENCODING));
         }
 
         // Header "CRC16" which is actually a truncated CRC32 (which isn't
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 8c1a0131..604398bb 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
@@ -18,8 +18,6 @@
  */
 package org.apache.commons.compress.compressors.gzip;
 
-import static java.nio.charset.StandardCharsets.ISO_8859_1;
-
 import java.io.IOException;
 import java.io.OutputStream;
 import java.nio.ByteBuffer;
@@ -197,12 +195,12 @@ public class GzipCompressorOutputStream extends CompressorOutputStream {
         out.write(buffer.array());
 
         if (filename != null) {
-            out.write(filename.getBytes(ISO_8859_1));
+            out.write(filename.getBytes(GzipUtils.GZIP_ENCODING));
             out.write(0);
         }
 
         if (comment != null) {
-            out.write(comment.getBytes(ISO_8859_1));
+            out.write(comment.getBytes(GzipUtils.GZIP_ENCODING));
             out.write(0);
         }
     }
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 b0cdb649..013adae2 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
@@ -18,6 +18,8 @@
  */
 package org.apache.commons.compress.compressors.gzip;
 
+import java.nio.charset.Charset;
+import java.nio.charset.StandardCharsets;
 import java.util.LinkedHashMap;
 import java.util.Map;
 
@@ -51,6 +53,11 @@ public class GzipUtils {
         fileNameUtil = new FileNameUtil(uncompressSuffix, ".gz");
     }
 
+    /**
+     * Encoding for file name and comments per the <a href="https://tools.ietf.org/html/rfc1952">GZIP File Format Specification</a>
+     */
+    static final Charset GZIP_ENCODING = StandardCharsets.ISO_8859_1;
+
     /**
      * Maps the given file name to the name that the file should have after
      * compression with gzip. Common file types with custom suffixes for