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 2022/12/28 22:46:35 UTC

[commons-compress] branch master updated (b7391964 -> be285193)

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 b7391964 Use Arrays.copyOf() and copyOfRange()
     new c3f4fc41 Format tweak
     new 095bcf7d Format tweak
     new be285193 Use Arrays.copyOf() and copyOfRange()

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:
 .../compress/archivers/zip/AbstractUnicodeExtraField.java     | 11 ++---------
 .../compress/archivers/zip/ZipArchiveOutputStream.java        |  4 ++--
 .../compressors/lz4/FramedLZ4CompressorInputStream.java       |  3 +--
 .../compressors/snappy/FramedSnappyCompressorInputStream.java |  3 +--
 4 files changed, 6 insertions(+), 15 deletions(-)


[commons-compress] 03/03: Use Arrays.copyOf() and copyOfRange()

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 be28519348a90ebc2649f1856d559dca2e23f2ab
Author: Gary Gregory <ga...@gmail.com>
AuthorDate: Wed Dec 28 17:46:30 2022 -0500

    Use Arrays.copyOf() and copyOfRange()
---
 .../compress/archivers/zip/AbstractUnicodeExtraField.java     | 11 ++---------
 .../compressors/lz4/FramedLZ4CompressorInputStream.java       |  3 +--
 .../compressors/snappy/FramedSnappyCompressorInputStream.java |  3 +--
 3 files changed, 4 insertions(+), 13 deletions(-)

diff --git a/src/main/java/org/apache/commons/compress/archivers/zip/AbstractUnicodeExtraField.java b/src/main/java/org/apache/commons/compress/archivers/zip/AbstractUnicodeExtraField.java
index ac9b2629..8e629442 100644
--- a/src/main/java/org/apache/commons/compress/archivers/zip/AbstractUnicodeExtraField.java
+++ b/src/main/java/org/apache/commons/compress/archivers/zip/AbstractUnicodeExtraField.java
@@ -122,12 +122,7 @@ public abstract class AbstractUnicodeExtraField implements ZipExtraField {
      * @return The UTF-8 encoded name.
      */
     public byte[] getUnicodeName() {
-        byte[] b = null;
-        if (unicodeName != null) {
-            b = new byte[unicodeName.length];
-            System.arraycopy(unicodeName, 0, b, 0, b.length);
-        }
-        return b;
+        return unicodeName != null ? Arrays.copyOf(unicodeName, unicodeName.length) : null;
     }
 
     /**
@@ -176,9 +171,7 @@ public abstract class AbstractUnicodeExtraField implements ZipExtraField {
      */
     public void setUnicodeName(final byte[] unicodeName) {
         if (unicodeName != null) {
-            this.unicodeName = new byte[unicodeName.length];
-            System.arraycopy(unicodeName, 0, this.unicodeName, 0,
-                             unicodeName.length);
+            this.unicodeName = Arrays.copyOf(unicodeName, unicodeName.length);
         } else {
             this.unicodeName = null;
         }
diff --git a/src/main/java/org/apache/commons/compress/compressors/lz4/FramedLZ4CompressorInputStream.java b/src/main/java/org/apache/commons/compress/compressors/lz4/FramedLZ4CompressorInputStream.java
index 3aabdad3..52ba760e 100644
--- a/src/main/java/org/apache/commons/compress/compressors/lz4/FramedLZ4CompressorInputStream.java
+++ b/src/main/java/org/apache/commons/compress/compressors/lz4/FramedLZ4CompressorInputStream.java
@@ -89,8 +89,7 @@ public class FramedLZ4CompressorInputStream extends CompressorInputStream
 
         byte[] shortenedSig = signature;
         if (signature.length > LZ4_SIGNATURE.length) {
-            shortenedSig = new byte[LZ4_SIGNATURE.length];
-            System.arraycopy(signature, 0, shortenedSig, 0, LZ4_SIGNATURE.length);
+            shortenedSig = Arrays.copyOf(signature, LZ4_SIGNATURE.length);
         }
 
         return Arrays.equals(shortenedSig, LZ4_SIGNATURE);
diff --git a/src/main/java/org/apache/commons/compress/compressors/snappy/FramedSnappyCompressorInputStream.java b/src/main/java/org/apache/commons/compress/compressors/snappy/FramedSnappyCompressorInputStream.java
index ccd18c8c..86f7bb70 100644
--- a/src/main/java/org/apache/commons/compress/compressors/snappy/FramedSnappyCompressorInputStream.java
+++ b/src/main/java/org/apache/commons/compress/compressors/snappy/FramedSnappyCompressorInputStream.java
@@ -78,8 +78,7 @@ public class FramedSnappyCompressorInputStream extends CompressorInputStream
 
         byte[] shortenedSig = signature;
         if (signature.length > SZ_SIGNATURE.length) {
-            shortenedSig = new byte[SZ_SIGNATURE.length];
-            System.arraycopy(signature, 0, shortenedSig, 0, SZ_SIGNATURE.length);
+            shortenedSig = Arrays.copyOf(signature, SZ_SIGNATURE.length);
         }
 
         return Arrays.equals(shortenedSig, SZ_SIGNATURE);


[commons-compress] 02/03: Format tweak

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 095bcf7da061fbcd18c8a95813f689f9a004c0c8
Author: Gary Gregory <ga...@gmail.com>
AuthorDate: Wed Dec 28 17:30:31 2022 -0500

    Format tweak
---
 .../apache/commons/compress/archivers/zip/ZipArchiveOutputStream.java   | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

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 4d06d680..e46c4d08 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
@@ -912,7 +912,7 @@ public class ZipArchiveOutputStream extends ArchiveOutputStream {
         final int len = LFH_FILENAME_OFFSET + nameLen + extra.length;
         final byte[] buf = new byte[len];
 
-        System.arraycopy(LFH_SIG,  0, buf, LFH_SIG_OFFSET, ZipConstants.WORD);
+        System.arraycopy(LFH_SIG, 0, buf, LFH_SIG_OFFSET, ZipConstants.WORD);
 
         //store method in local variable to prevent multiple method calls
         final int zipMethod = ze.getMethod();


[commons-compress] 01/03: Format tweak

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 c3f4fc410c4c098876dca98c364438a0b9133224
Author: Gary Gregory <ga...@gmail.com>
AuthorDate: Wed Dec 28 17:30:19 2022 -0500

    Format tweak
---
 .../apache/commons/compress/archivers/zip/ZipArchiveOutputStream.java   | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

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 30e939ee..4d06d680 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
@@ -802,7 +802,7 @@ public class ZipArchiveOutputStream extends ArchiveOutputStream {
         final int len= CFH_FILENAME_OFFSET + nameLen + extraLength + commentLen;
         final byte[] buf = new byte[len];
 
-        System.arraycopy(CFH_SIG,  0, buf, CFH_SIG_OFFSET, ZipConstants.WORD);
+        System.arraycopy(CFH_SIG, 0, buf, CFH_SIG_OFFSET, ZipConstants.WORD);
 
         // version made by
         // CheckStyle:MagicNumber OFF