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/08 16:15:31 UTC

[commons-compress] branch master updated (221d72d9 -> d5949db4)

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 221d72d9 Replace FindBugs with SpotBugs and declutter the root folder
     new 8895dab3 Use simple array initialization
     new bb90215e Remove trailing whitespace
     new 0f88243c Use simple array initialization
     new 3fd944d5 Use final parameter
     new 7d2a465e Use final parameter
     new f4021b00 Use Java Objects class
     new d8a4b5b2 Remove redundant call to super()
     new acf8db36 Remove trailing whitespace
     new f5ee4390 Convert cascading if/else to switch
     new dd879752 Remove trailing whitespace
     new 9c834159 Remove trailing whitespace
     new 94a4ad22 Convert cascading if/else to switch
     new 77761990 Use enhanced for loop
     new 1ce3c8ea Use Java Objects class
     new 9752f9d1 Use Java Objects class
     new 189b4f8e Use Java Objects class
     new 09f1c972 Remove trailing whitespace
     new 4c737168 Use final parameter
     new b4af7d3c Use simple array initialization
     new 12c311a8 Use simple array initialization
     new c3c19e56 Use simple array initialization
     new 1263e7ca Use simple array initialization
     new 3b8c339f Use final parameter
     new f07a2fea Use simple array initialization
     new c6314a9f Remove trailing whitespace
     new 007b09b0 Convert cascading if/else to switch
     new 37c2c30d Convert cascading if/else to switch
     new 3c86561d Use simple array initialization
     new 0b34836e Convert cascading if/else to switch
     new 40d6d6c8 Remove redundant call to super()
     new 36f2d6e8 Make private class static
     new 6abbaeac Use simple array initialization
     new fe2cb6a8 Use Java Objects class
     new 1654cd20 Use final parameter
     new 31af6373 Remove trailing whitespace
     new 1f0fa35b Use final parameter
     new ded9898c Use final parameter
     new d5949db4 Use final parameter

The 38 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/ArchiveStreamFactory.java   |  2 +-
 .../apache/commons/compress/archivers/Lister.java  |  2 +-
 .../compress/archivers/arj/ArjArchiveEntry.java    |  4 +-
 .../compress/archivers/cpio/CpioConstants.java     |  2 +-
 .../archivers/dump/DumpArchiveSummary.java         |  2 +-
 .../commons/compress/archivers/sevenz/Archive.java |  2 +-
 .../commons/compress/archivers/sevenz/Folder.java  |  2 +-
 .../archivers/sevenz/SevenZArchiveEntry.java       |  4 +-
 .../compress/archivers/tar/TarArchiveEntry.java    |  8 +--
 .../compress/archivers/tar/TarConstants.java       | 12 ++--
 .../commons/compress/archivers/tar/TarUtils.java   |  4 +-
 .../compress/archivers/zip/ExtraFieldUtils.java    |  2 +-
 .../compress/archivers/zip/NioZipEncoding.java     |  2 +-
 .../archivers/zip/ZipArchiveInputStream.java       | 10 +--
 .../compress/archivers/zip/ZipEncodingHelper.java  |  2 +-
 .../bzip2/BZip2CompressorOutputStream.java         |  2 +-
 .../compress/compressors/gzip/GzipParameters.java  |  2 +-
 .../lz4/BlockLZ4CompressorOutputStream.java        | 26 +++----
 .../lz4/FramedLZ4CompressorInputStream.java        |  4 +-
 .../pack200/Pack200CompressorInputStream.java      |  2 +-
 .../snappy/FramedSnappyCompressorInputStream.java  |  2 +-
 .../compressors/snappy/PureJavaCrc32C.java         |  2 +-
 .../compress/harmony/pack200/BHSDCodec.java        | 12 ++--
 .../commons/compress/harmony/pack200/BcBands.java  |  2 +-
 .../compress/harmony/pack200/ClassBands.java       | 29 +++++---
 .../compress/harmony/pack200/PackingOptions.java   |  2 +-
 .../compress/harmony/pack200/SegmentHeader.java    |  2 +-
 .../harmony/unpack200/AttributeLayout.java         |  1 -
 .../compress/harmony/unpack200/ClassBands.java     | 56 +++++++--------
 .../compress/harmony/unpack200/IcTuple.java        |  2 +-
 .../harmony/unpack200/NewAttributeBands.java       | 14 ++--
 .../harmony/unpack200/SegmentConstantPool.java     | 79 ++++++++++------------
 .../unpack200/SegmentConstantPoolArrayCache.java   |  1 -
 .../harmony/unpack200/bytecode/Attribute.java      | 12 +---
 .../harmony/unpack200/bytecode/CPConstant.java     | 11 +--
 .../harmony/unpack200/bytecode/CPFieldRef.java     | 13 +---
 .../unpack200/bytecode/ConstantValueAttribute.java |  6 +-
 .../harmony/unpack200/bytecode/NewAttribute.java   | 15 ++--
 .../unpack200/bytecode/SourceFileAttribute.java    |  7 +-
 .../compress/utils/BoundedArchiveInputStream.java  |  2 +-
 .../BoundedSeekableByteChannelInputStream.java     |  2 +-
 .../apache/commons/compress/utils/ByteUtils.java   |  2 +-
 42 files changed, 179 insertions(+), 191 deletions(-)


[commons-compress] 14/38: Use Java Objects class

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 1ce3c8ea5b00e8e2551f56563d0668ea352e9090
Author: Gary Gregory <ga...@gmail.com>
AuthorDate: Thu Dec 8 11:06:30 2022 -0500

    Use Java Objects class
---
 .../compress/harmony/unpack200/bytecode/ConstantValueAttribute.java | 6 +-----
 1 file changed, 1 insertion(+), 5 deletions(-)

diff --git a/src/main/java/org/apache/commons/compress/harmony/unpack200/bytecode/ConstantValueAttribute.java b/src/main/java/org/apache/commons/compress/harmony/unpack200/bytecode/ConstantValueAttribute.java
index 8f321c0b..f0319972 100644
--- a/src/main/java/org/apache/commons/compress/harmony/unpack200/bytecode/ConstantValueAttribute.java
+++ b/src/main/java/org/apache/commons/compress/harmony/unpack200/bytecode/ConstantValueAttribute.java
@@ -52,11 +52,7 @@ public class ConstantValueAttribute extends Attribute {
             return false;
         }
         final ConstantValueAttribute other = (ConstantValueAttribute) obj;
-        if (entry == null) {
-            if (other.entry != null) {
-                return false;
-            }
-        } else if (!entry.equals(other.entry)) {
+        if (!Objects.equals(entry, other.entry)) {
             return false;
         }
         return true;


[commons-compress] 23/38: Use final parameter

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 3b8c339fcae102bfec79526e1e14ae26fae0003d
Author: Gary Gregory <ga...@gmail.com>
AuthorDate: Thu Dec 8 11:08:40 2022 -0500

    Use final parameter
---
 .../org/apache/commons/compress/compressors/gzip/GzipParameters.java    | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/main/java/org/apache/commons/compress/compressors/gzip/GzipParameters.java b/src/main/java/org/apache/commons/compress/compressors/gzip/GzipParameters.java
index 051eb67d..83cf9e62 100644
--- a/src/main/java/org/apache/commons/compress/compressors/gzip/GzipParameters.java
+++ b/src/main/java/org/apache/commons/compress/compressors/gzip/GzipParameters.java
@@ -138,7 +138,7 @@ public class GzipParameters {
      * @param bufferSize the bufferSize to set. Must be a positive value.
      * @since 1.21
      */
-    public void setBufferSize(int bufferSize) {
+    public void setBufferSize(final int bufferSize) {
         if (bufferSize <= 0) {
             throw new IllegalArgumentException("invalid buffer size: " + bufferSize);
         }


[commons-compress] 37/38: Use final parameter

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 ded9898cd42fb31a002244ec07681b821658207b
Author: Gary Gregory <ga...@gmail.com>
AuthorDate: Thu Dec 8 11:15:20 2022 -0500

    Use final parameter
    
    Use simpler array declaration
    Remove trailing whitespace
---
 .../commons/compress/archivers/zip/ZipArchiveInputStream.java  | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/src/main/java/org/apache/commons/compress/archivers/zip/ZipArchiveInputStream.java b/src/main/java/org/apache/commons/compress/archivers/zip/ZipArchiveInputStream.java
index bd98ba10..eebb261c 100644
--- a/src/main/java/org/apache/commons/compress/archivers/zip/ZipArchiveInputStream.java
+++ b/src/main/java/org/apache/commons/compress/archivers/zip/ZipArchiveInputStream.java
@@ -557,8 +557,8 @@ public class ZipArchiveInputStream extends ArchiveInputStream implements InputSt
         if (method == ZipArchiveOutputStream.DEFLATED) {
             return getBytesInflated();
         }
-        if (method == ZipMethod.UNSHRINKING.getCode() 
-            || method == ZipMethod.IMPLODING.getCode() 
+        if (method == ZipMethod.UNSHRINKING.getCode()
+            || method == ZipMethod.IMPLODING.getCode()
             || method == ZipMethod.ENHANCED_DEFLATED.getCode()
             || method == ZipMethod.BZIP2.getCode()) {
             return ((InputStreamStatistics) current.checkInputStream()).getCompressedCount();
@@ -876,7 +876,7 @@ public class ZipArchiveInputStream extends ArchiveInputStream implements InputSt
         }
     }
 
-    private byte[] readRange(int len) throws IOException {
+    private byte[] readRange(final int len) throws IOException {
         final byte[] ret = IOUtils.readRange(inputStream, len);
         count(ret.length);
         if (ret.length < len) {
@@ -1216,7 +1216,7 @@ public class ZipArchiveInputStream extends ArchiveInputStream implements InputSt
         return b == ZipArchiveOutputStream.EOCD_SIG[0];
     }
 
-    private static final byte[] APK_SIGNING_BLOCK_MAGIC = new byte[] {
+    private static final byte[] APK_SIGNING_BLOCK_MAGIC = {
         'A', 'P', 'K', ' ', 'S', 'i', 'g', ' ', 'B', 'l', 'o', 'c', 'k', ' ', '4', '2',
     };
     private static final BigInteger LONG_MAX = BigInteger.valueOf(Long.MAX_VALUE);
@@ -1317,7 +1317,7 @@ public class ZipArchiveInputStream extends ArchiveInputStream implements InputSt
          * The input stream decompressing the data for shrunk and imploded entries.
          */
         private InputStream inputStream;
-        
+
         @SuppressWarnings("unchecked") // Caller beware
         private <T extends InputStream> T checkInputStream() {
             return (T) Objects.requireNonNull(inputStream, "inputStream");


[commons-compress] 26/38: Convert cascading if/else to switch

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 007b09b08ed6c7ca6deee1e341d0f20ed754af9d
Author: Gary Gregory <ga...@gmail.com>
AuthorDate: Thu Dec 8 11:09:11 2022 -0500

    Convert cascading if/else to switch
---
 .../compress/harmony/unpack200/bytecode/NewAttribute.java | 15 +++++++++++----
 1 file changed, 11 insertions(+), 4 deletions(-)

diff --git a/src/main/java/org/apache/commons/compress/harmony/unpack200/bytecode/NewAttribute.java b/src/main/java/org/apache/commons/compress/harmony/unpack200/bytecode/NewAttribute.java
index 1b3220eb..4d942fc7 100644
--- a/src/main/java/org/apache/commons/compress/harmony/unpack200/bytecode/NewAttribute.java
+++ b/src/main/java/org/apache/commons/compress/harmony/unpack200/bytecode/NewAttribute.java
@@ -73,14 +73,21 @@ public class NewAttribute extends BCIRenumberedAttribute {
                 value = ((BCValue) obj).actualValue;
             }
             // Write
-            if (length == 1) {
+            switch (length) {
+            case 1:
                 dos.writeByte((int) value);
-            } else if (length == 2) {
+                break;
+            case 2:
                 dos.writeShort((int) value);
-            } else if (length == 4) {
+                break;
+            case 4:
                 dos.writeInt((int) value);
-            } else if (length == 8) {
+                break;
+            case 8:
                 dos.writeLong(value);
+                break;
+            default:
+                break;
             }
         }
     }


[commons-compress] 11/38: Remove trailing whitespace

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 9c834159a253a1da4e4c5df05a81985c0b1c0ef7
Author: Gary Gregory <ga...@gmail.com>
AuthorDate: Thu Dec 8 11:05:16 2022 -0500

    Remove trailing whitespace
---
 .../commons/compress/compressors/bzip2/BZip2CompressorOutputStream.java | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/main/java/org/apache/commons/compress/compressors/bzip2/BZip2CompressorOutputStream.java b/src/main/java/org/apache/commons/compress/compressors/bzip2/BZip2CompressorOutputStream.java
index f0887232..22f058f6 100644
--- a/src/main/java/org/apache/commons/compress/compressors/bzip2/BZip2CompressorOutputStream.java
+++ b/src/main/java/org/apache/commons/compress/compressors/bzip2/BZip2CompressorOutputStream.java
@@ -1198,7 +1198,7 @@ public class BZip2CompressorOutputStream extends CompressorOutputStream
         for (int i = nInUseShadow; --i >= 0;) {
             yy[i] = (byte) i;
         }
-        
+
         int wr = 0;
         int zPend = 0;
 


[commons-compress] 03/38: Use simple array initialization

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 0f88243cc4b956ee00e829c7c2b9724a3a22a145
Author: Gary Gregory <ga...@gmail.com>
AuthorDate: Thu Dec 8 11:02:31 2022 -0500

    Use simple array initialization
---
 src/main/java/org/apache/commons/compress/utils/ByteUtils.java | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/main/java/org/apache/commons/compress/utils/ByteUtils.java b/src/main/java/org/apache/commons/compress/utils/ByteUtils.java
index f00e875c..25464323 100644
--- a/src/main/java/org/apache/commons/compress/utils/ByteUtils.java
+++ b/src/main/java/org/apache/commons/compress/utils/ByteUtils.java
@@ -35,7 +35,7 @@ public final class ByteUtils {
      *
      * @since 1.21
      */
-    public static final byte[] EMPTY_BYTE_ARRAY = new byte[0];
+    public static final byte[] EMPTY_BYTE_ARRAY = {};
 
     private ByteUtils() { /* no instances */ }
 


[commons-compress] 13/38: Use enhanced for loop

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 77761990c9e9af8300403ff4e8d2244fefdb88a8
Author: Gary Gregory <ga...@gmail.com>
AuthorDate: Thu Dec 8 11:06:16 2022 -0500

    Use enhanced for loop
---
 .../compress/harmony/unpack200/ClassBands.java     | 56 +++++++++++-----------
 1 file changed, 28 insertions(+), 28 deletions(-)

diff --git a/src/main/java/org/apache/commons/compress/harmony/unpack200/ClassBands.java b/src/main/java/org/apache/commons/compress/harmony/unpack200/ClassBands.java
index bf0fa5c9..8ed828ea 100644
--- a/src/main/java/org/apache/commons/compress/harmony/unpack200/ClassBands.java
+++ b/src/main/java/org/apache/commons/compress/harmony/unpack200/ClassBands.java
@@ -400,17 +400,17 @@ public class ClassBands extends BandSet {
 
     private int getCallCount(final int[][] methodAttrIndexes, final long[][] flags, final int context) {
         int callCount = 0;
-        for (int i = 0; i < methodAttrIndexes.length; i++) {
-            for (int j = 0; j < methodAttrIndexes[i].length; j++) {
-                final int index = methodAttrIndexes[i][j];
+        for (int[] element : methodAttrIndexes) {
+            for (int j = 0; j < element.length; j++) {
+                final int index = element[j];
                 final AttributeLayout layout = attrMap.getAttributeLayout(index, context);
                 callCount += layout.numBackwardsCallables();
             }
         }
         int layoutsUsed = 0;
-        for (int i = 0; i < flags.length; i++) {
-            for (int j = 0; j < flags[i].length; j++) {
-                layoutsUsed |= flags[i][j];
+        for (long[] flag : flags) {
+            for (int j = 0; j < flag.length; j++) {
+                layoutsUsed |= flag[j];
             }
         }
         for (int i = 0; i < 26; i++) {
@@ -469,9 +469,9 @@ public class ClassBands extends BandSet {
         final int[][] classInnerClassesF = decodeBandInt("class_InnerClasses_F", in, Codec.UNSIGNED5,
             classInnerClassesN);
         int flagsCount = 0;
-        for (int i = 0; i < classInnerClassesF.length; i++) {
-            for (int j = 0; j < classInnerClassesF[i].length; j++) {
-                if (classInnerClassesF[i][j] != 0) {
+        for (int[] element : classInnerClassesF) {
+            for (int j = 0; j < element.length; j++) {
+                if (element[j] != 0) {
                     flagsCount++;
                 }
             }
@@ -600,11 +600,11 @@ public class ClassBands extends BandSet {
                         // Get from icBands
                         final IcBands icBands = segment.getIcBands();
                         final IcTuple[] icAll = icBands.getIcTuples();
-                        for (int k = 0; k < icAll.length; k++) {
-                            if (icAll[k].getC().equals(icTupleC)) {
-                                icTupleF = icAll[k].getF();
-                                icTupleC2 = icAll[k].getC2();
-                                icTupleN = icAll[k].getN();
+                        for (IcTuple element : icAll) {
+                            if (element.getC().equals(icTupleC)) {
+                                icTupleF = element.getF();
+                                icTupleC2 = element.getC2();
+                                icTupleN = element.getN();
                                 break;
                             }
                         }
@@ -712,9 +712,9 @@ public class ClassBands extends BandSet {
         final int[] codeAttrCounts = decodeBandInt("code_attr_count", in, Codec.UNSIGNED5, codeAttrCount);
         final int[][] codeAttrIndexes = decodeBandInt("code_attr_indexes", in, Codec.UNSIGNED5, codeAttrCounts);
         int callCount = 0;
-        for (int i = 0; i < codeAttrIndexes.length; i++) {
-            for (int j = 0; j < codeAttrIndexes[i].length; j++) {
-                final int index = codeAttrIndexes[i][j];
+        for (int[] element : codeAttrIndexes) {
+            for (int j = 0; j < element.length; j++) {
+                final int index = element[j];
                 final AttributeLayout layout = attrMap.getAttributeLayout(index, AttributeLayout.CONTEXT_CODE);
                 callCount += layout.numBackwardsCallables();
             }
@@ -888,9 +888,9 @@ public class ClassBands extends BandSet {
                 mbg[i].type_RS = parseCPSignatureReferences(contextName + "_" + rxa + "_type_RS", in, Codec.UNSIGNED5,
                     mbg[i].anno_N);
                 mbg[i].pair_N = decodeBandInt(contextName + "_" + rxa + "_pair_N", in, Codec.UNSIGNED5, mbg[i].anno_N);
-                for (int j = 0; j < mbg[i].pair_N.length; j++) {
-                    for (int k = 0; k < mbg[i].pair_N[j].length; k++) {
-                        pairCount += mbg[i].pair_N[j][k];
+                for (int[] element : mbg[i].pair_N) {
+                    for (int k = 0; k < element.length; k++) {
+                        pairCount += element[k];
                     }
                 }
 
@@ -903,8 +903,8 @@ public class ClassBands extends BandSet {
                 pairCount + backwardsCallCounts[i]);
             int ICount = 0, DCount = 0, FCount = 0, JCount = 0, cCount = 0, eCount = 0, sCount = 0, arrayCount = 0,
                 atCount = 0;
-            for (int j = 0; j < mbg[i].T.length; j++) {
-                final char c = (char) mbg[i].T[j];
+            for (int element : mbg[i].T) {
+                final char c = (char) element;
                 switch (c) {
                 case 'B':
                 case 'C':
@@ -958,8 +958,8 @@ public class ClassBands extends BandSet {
                 atCount);
             mbg[i].nestpair_N = decodeBandInt(contextName + "_" + rxa + "_nestpair_N", in, Codec.UNSIGNED5, atCount);
             int nestPairCount = 0;
-            for (int j = 0; j < mbg[i].nestpair_N.length; j++) {
-                nestPairCount += mbg[i].nestpair_N[j];
+            for (int element : mbg[i].nestpair_N) {
+                nestPairCount += element;
             }
             mbg[i].nestname_RU = parseCPUTF8References(contextName + "_" + rxa + "_nestname_RU", in, Codec.UNSIGNED5,
                 nestPairCount);
@@ -1159,10 +1159,10 @@ public class ClassBands extends BandSet {
      */
     public ArrayList<List<Attribute>> getOrderedCodeAttributes() {
         final ArrayList<List<Attribute>> orderedAttributeList = new ArrayList<>(codeAttributes.length);
-        for (int classIndex = 0; classIndex < codeAttributes.length; classIndex++) {
-            final List<Attribute> currentAttributes = new ArrayList<>(codeAttributes[classIndex].size());
-            for (int attributeIndex = 0; attributeIndex < codeAttributes[classIndex].size(); attributeIndex++) {
-                currentAttributes.add(codeAttributes[classIndex].get(attributeIndex));
+        for (List<Attribute> codeAttribute : codeAttributes) {
+            final List<Attribute> currentAttributes = new ArrayList<>(codeAttribute.size());
+            for (int attributeIndex = 0; attributeIndex < codeAttribute.size(); attributeIndex++) {
+                currentAttributes.add(codeAttribute.get(attributeIndex));
             }
             orderedAttributeList.add(currentAttributes);
         }


[commons-compress] 29/38: Convert cascading if/else to switch

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 0b34836e188c60bf0232644a0809a3f8910df1ea
Author: Gary Gregory <ga...@gmail.com>
AuthorDate: Thu Dec 8 11:11:06 2022 -0500

    Convert cascading if/else to switch
---
 .../harmony/unpack200/SegmentConstantPool.java     | 79 ++++++++++------------
 1 file changed, 35 insertions(+), 44 deletions(-)

diff --git a/src/main/java/org/apache/commons/compress/harmony/unpack200/SegmentConstantPool.java b/src/main/java/org/apache/commons/compress/harmony/unpack200/SegmentConstantPool.java
index 09e77a96..edbd2317 100644
--- a/src/main/java/org/apache/commons/compress/harmony/unpack200/SegmentConstantPool.java
+++ b/src/main/java/org/apache/commons/compress/harmony/unpack200/SegmentConstantPool.java
@@ -65,32 +65,27 @@ public class SegmentConstantPool {
         if (index < 0) {
             throw new Pack200Exception("Cannot have a negative range");
         }
-        if (cp == UTF_8) {
+        switch (cp) {
+        case UTF_8:
             return bands.cpUTF8Value(index);
-        }
-        if (cp == CP_INT) {
+        case CP_INT:
             return bands.cpIntegerValue(index);
-        }
-        if (cp == CP_FLOAT) {
+        case CP_FLOAT:
             return bands.cpFloatValue(index);
-        }
-        if (cp == CP_LONG) {
+        case CP_LONG:
             return bands.cpLongValue(index);
-        }
-        if (cp == CP_DOUBLE) {
+        case CP_DOUBLE:
             return bands.cpDoubleValue(index);
-        }
-        if (cp == CP_STRING) {
+        case CP_STRING:
             return bands.cpStringValue(index);
-        }
-        if (cp == CP_CLASS) {
+        case CP_CLASS:
             return bands.cpClassValue(index);
-        }
-        if (cp == SIGNATURE) {
+        case SIGNATURE:
             return bands.cpSignatureValue(index);
-        }
-        if (cp == CP_DESCR) {
+        case CP_DESCR:
             return bands.cpNameAndTypeValue(index);
+        default:
+            break;
         }
         throw new Error("Tried to get a value I don't know about: " + cp);
     }
@@ -110,13 +105,17 @@ public class SegmentConstantPool {
         final int index = (int) desiredIndex;
         int realIndex = -1;
         String[] array = null;
-        if (cp == CP_FIELD) {
+        switch (cp) {
+        case CP_FIELD:
             array = bands.getCpFieldClass();
-        } else if (cp == CP_METHOD) {
+            break;
+        case CP_METHOD:
             array = bands.getCpMethodClass();
-        } else if (cp == CP_IMETHOD) {
+            break;
+        case CP_IMETHOD:
             array = bands.getCpIMethodClass();
-        } else {
+            break;
+        default:
             throw new Error("Don't know how to handle " + cp);
         }
         realIndex = matchSpecificPoolEntryIndex(array, desiredClassName, index);
@@ -255,44 +254,36 @@ public class SegmentConstantPool {
         if (index < 0) {
             throw new Pack200Exception("Cannot have a negative range");
         }
-        if (cp == UTF_8) {
+        switch (cp) {
+        case UTF_8:
             return bands.cpUTF8Value(index);
-        }
-        if (cp == CP_INT) {
+        case CP_INT:
             return bands.cpIntegerValue(index);
-        }
-        if (cp == CP_FLOAT) {
+        case CP_FLOAT:
             return bands.cpFloatValue(index);
-        }
-        if (cp == CP_LONG) {
+        case CP_LONG:
             return bands.cpLongValue(index);
-        }
-        if (cp == CP_DOUBLE) {
+        case CP_DOUBLE:
             return bands.cpDoubleValue(index);
-        }
-        if (cp == CP_STRING) {
+        case CP_STRING:
             return bands.cpStringValue(index);
-        }
-        if (cp == CP_CLASS) {
+        case CP_CLASS:
             return bands.cpClassValue(index);
-        }
-        if (cp == SIGNATURE) {
+        case SIGNATURE:
             throw new Error("I don't know what to do with signatures yet");
             // return null /* new CPSignature(bands.getCpSignature()[index]) */;
-        }
-        if (cp == CP_DESCR) {
+        case CP_DESCR:
             throw new Error("I don't know what to do with descriptors yet");
             // return null /* new CPDescriptor(bands.getCpDescriptor()[index])
             // */;
-        }
-        if (cp == CP_FIELD) {
+        case CP_FIELD:
             return bands.cpFieldValue(index);
-        }
-        if (cp == CP_METHOD) {
+        case CP_METHOD:
             return bands.cpMethodValue(index);
-        }
-        if (cp == CP_IMETHOD) {
+        case CP_IMETHOD:
             return bands.cpIMethodValue(index);
+        default:
+            break;
         }
         // etc
         throw new Error("Get value incomplete");


[commons-compress] 07/38: Remove redundant call to super()

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 d8a4b5b2b29fc9618d88ae279def97d15c9dafcd
Author: Gary Gregory <ga...@gmail.com>
AuthorDate: Thu Dec 8 11:04:16 2022 -0500

    Remove redundant call to super()
---
 .../org/apache/commons/compress/harmony/unpack200/AttributeLayout.java   | 1 -
 1 file changed, 1 deletion(-)

diff --git a/src/main/java/org/apache/commons/compress/harmony/unpack200/AttributeLayout.java b/src/main/java/org/apache/commons/compress/harmony/unpack200/AttributeLayout.java
index c554de14..41e07726 100644
--- a/src/main/java/org/apache/commons/compress/harmony/unpack200/AttributeLayout.java
+++ b/src/main/java/org/apache/commons/compress/harmony/unpack200/AttributeLayout.java
@@ -127,7 +127,6 @@ public class AttributeLayout implements IMatcher {
 
     public AttributeLayout(final String name, final int context, final String layout, final int index,
         final boolean isDefault) throws Pack200Exception {
-        super();
         this.index = index;
         this.context = context;
         if (index >= 0) {


[commons-compress] 18/38: Use final parameter

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 4c737168466b254453c34b03c7a9cd9ff2a1be58
Author: Gary Gregory <ga...@gmail.com>
AuthorDate: Thu Dec 8 11:07:35 2022 -0500

    Use final parameter
---
 .../org/apache/commons/compress/archivers/dump/DumpArchiveSummary.java  | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/main/java/org/apache/commons/compress/archivers/dump/DumpArchiveSummary.java b/src/main/java/org/apache/commons/compress/archivers/dump/DumpArchiveSummary.java
index 53949e2b..b197564c 100644
--- a/src/main/java/org/apache/commons/compress/archivers/dump/DumpArchiveSummary.java
+++ b/src/main/java/org/apache/commons/compress/archivers/dump/DumpArchiveSummary.java
@@ -294,7 +294,7 @@ public class DumpArchiveSummary {
     }
 
     @Override
-    public boolean equals(Object obj) {
+    public boolean equals(final Object obj) {
         if (this == obj) {
             return true;
         }


[commons-compress] 28/38: Use simple array initialization

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 3c86561deb98d99373720b833085f98746ade9a4
Author: Gary Gregory <ga...@gmail.com>
AuthorDate: Thu Dec 8 11:10:54 2022 -0500

    Use simple array initialization
---
 .../java/org/apache/commons/compress/archivers/zip/NioZipEncoding.java  | 2 +-
 .../compress/compressors/pack200/Pack200CompressorInputStream.java      | 2 +-
 .../org/apache/commons/compress/compressors/snappy/PureJavaCrc32C.java  | 2 +-
 .../org/apache/commons/compress/harmony/pack200/PackingOptions.java     | 2 +-
 4 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/src/main/java/org/apache/commons/compress/archivers/zip/NioZipEncoding.java b/src/main/java/org/apache/commons/compress/archivers/zip/NioZipEncoding.java
index 19bdfdce..772099c1 100644
--- a/src/main/java/org/apache/commons/compress/archivers/zip/NioZipEncoding.java
+++ b/src/main/java/org/apache/commons/compress/archivers/zip/NioZipEncoding.java
@@ -41,7 +41,7 @@ class NioZipEncoding implements ZipEncoding, CharsetAccessor {
     private static final char REPLACEMENT = '?';
     private static final byte[] REPLACEMENT_BYTES = { (byte) REPLACEMENT };
     private static final String REPLACEMENT_STRING = String.valueOf(REPLACEMENT);
-    private static final char[] HEX_CHARS = new char[] {
+    private static final char[] HEX_CHARS = {
         '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F'
     };
 
diff --git a/src/main/java/org/apache/commons/compress/compressors/pack200/Pack200CompressorInputStream.java b/src/main/java/org/apache/commons/compress/compressors/pack200/Pack200CompressorInputStream.java
index a9fdbf11..f0bb1783 100644
--- a/src/main/java/org/apache/commons/compress/compressors/pack200/Pack200CompressorInputStream.java
+++ b/src/main/java/org/apache/commons/compress/compressors/pack200/Pack200CompressorInputStream.java
@@ -249,7 +249,7 @@ public class Pack200CompressorInputStream extends CompressorInputStream {
         }
     }
 
-    private static final byte[] CAFE_DOOD = new byte[] {
+    private static final byte[] CAFE_DOOD = {
         (byte) 0xCA, (byte) 0xFE, (byte) 0xD0, (byte) 0x0D
     };
     private static final int SIG_LENGTH = CAFE_DOOD.length;
diff --git a/src/main/java/org/apache/commons/compress/compressors/snappy/PureJavaCrc32C.java b/src/main/java/org/apache/commons/compress/compressors/snappy/PureJavaCrc32C.java
index 01cfaee4..48d2b7bf 100644
--- a/src/main/java/org/apache/commons/compress/compressors/snappy/PureJavaCrc32C.java
+++ b/src/main/java/org/apache/commons/compress/compressors/snappy/PureJavaCrc32C.java
@@ -113,7 +113,7 @@ final class PureJavaCrc32C implements Checksum {
   private static final int T8_6_START = 6*256;
   private static final int T8_7_START = 7*256;
 
-  private static final int[] T = new int[] {
+  private static final int[] T = {
     /* T8_0 */
     0x00000000, 0xF26B8303, 0xE13B70F7, 0x1350F3F4,
     0xC79A971F, 0x35F1141C, 0x26A1E7E8, 0xD4CA64EB,
diff --git a/src/main/java/org/apache/commons/compress/harmony/pack200/PackingOptions.java b/src/main/java/org/apache/commons/compress/harmony/pack200/PackingOptions.java
index b6d37273..c11ffd78 100644
--- a/src/main/java/org/apache/commons/compress/harmony/pack200/PackingOptions.java
+++ b/src/main/java/org/apache/commons/compress/harmony/pack200/PackingOptions.java
@@ -28,7 +28,7 @@ import org.objectweb.asm.Attribute;
  */
 public class PackingOptions {
 
-    private static final Attribute[] EMPTY_ATTRIBUTE_ARRAY = new Attribute[0];
+    private static final Attribute[] EMPTY_ATTRIBUTE_ARRAY = {};
     public static final long SEGMENT_LIMIT = 1_000_000L;
     public static final String STRIP = "strip";
     public static final String ERROR = "error";


[commons-compress] 34/38: Use final parameter

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 1654cd20ab2f9acff53ca7ab70a6ea3d1e20ed9b
Author: Gary Gregory <ga...@gmail.com>
AuthorDate: Thu Dec 8 11:13:33 2022 -0500

    Use final parameter
    
    Use simpler array declaration
---
 .../apache/commons/compress/archivers/tar/TarArchiveEntry.java    | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/src/main/java/org/apache/commons/compress/archivers/tar/TarArchiveEntry.java b/src/main/java/org/apache/commons/compress/archivers/tar/TarArchiveEntry.java
index 63b60cfb..9efe9976 100644
--- a/src/main/java/org/apache/commons/compress/archivers/tar/TarArchiveEntry.java
+++ b/src/main/java/org/apache/commons/compress/archivers/tar/TarArchiveEntry.java
@@ -130,7 +130,7 @@ import org.apache.commons.compress.utils.TimeUtils;
  *   char unused_pad[17];   // TarConstants.PAD3LEN_GNU       - offset 495
  * };
  * </pre>
- * <p> 
+ * <p>
  * Whereas, "struct sparse" is:
  * </p>
  * <pre>
@@ -193,7 +193,7 @@ import org.apache.commons.compress.utils.TimeUtils;
  */
 public class TarArchiveEntry implements ArchiveEntry, TarConstants, EntryStreamOffsets {
 
-    private static final TarArchiveEntry[] EMPTY_TAR_ARCHIVE_ENTRY_ARRAY = new TarArchiveEntry[0];
+    private static final TarArchiveEntry[] EMPTY_TAR_ARCHIVE_ENTRY_ARRAY = {};
 
     /**
      * Value used to indicate unknown mode, user/groupids, device numbers and modTime when parsing a file in lenient
@@ -218,7 +218,7 @@ public class TarArchiveEntry implements ArchiveEntry, TarConstants, EntryStreamO
     @Deprecated
     public static final int MILLIS_PER_SECOND = 1000;
 
-    private static FileTime fileTimeFromOptionalSeconds(long seconds) {
+    private static FileTime fileTimeFromOptionalSeconds(final long seconds) {
         if (seconds <= 0) {
             return null;
         }
@@ -2123,7 +2123,7 @@ public class TarArchiveEntry implements ArchiveEntry, TarConstants, EntryStreamO
                                                      length);
     }
 
-    private int writeEntryHeaderOptionalTimeField(FileTime time, int offset, byte[] outbuf, int fieldLength) {
+    private int writeEntryHeaderOptionalTimeField(final FileTime time, int offset, final byte[] outbuf, final int fieldLength) {
         if (time != null) {
             offset = writeEntryHeaderField(time.to(TimeUnit.SECONDS), outbuf, offset, fieldLength, true);
         } else {


[commons-compress] 36/38: Use final parameter

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 1f0fa35bc80429d4f3ca07abf1f0bf658b54cdcf
Author: Gary Gregory <ga...@gmail.com>
AuthorDate: Thu Dec 8 11:15:06 2022 -0500

    Use final parameter
---
 src/main/java/org/apache/commons/compress/archivers/tar/TarUtils.java | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/src/main/java/org/apache/commons/compress/archivers/tar/TarUtils.java b/src/main/java/org/apache/commons/compress/archivers/tar/TarUtils.java
index 69922133..56a06757 100644
--- a/src/main/java/org/apache/commons/compress/archivers/tar/TarUtils.java
+++ b/src/main/java/org/apache/commons/compress/archivers/tar/TarUtils.java
@@ -851,7 +851,7 @@ public class TarUtils {
      * @deprecated use #parseFromPAX01SparseHeaders instead
      */
     @Deprecated
-    protected static List<TarArchiveStructSparse> parsePAX01SparseHeaders(String sparseMap) {
+    protected static List<TarArchiveStructSparse> parsePAX01SparseHeaders(final String sparseMap) {
         try {
             return parseFromPAX01SparseHeaders(sparseMap);
         } catch (IOException ex) {
@@ -869,7 +869,7 @@ public class TarUtils {
      * @throws IOException Corrupted TAR archive.
      * @since 1.21
      */
-    protected static List<TarArchiveStructSparse> parseFromPAX01SparseHeaders(String sparseMap)
+    protected static List<TarArchiveStructSparse> parseFromPAX01SparseHeaders(final String sparseMap)
         throws IOException {
         List<TarArchiveStructSparse> sparseHeaders = new ArrayList<>();
         String[] sparseHeaderStrings = sparseMap.split(",");


[commons-compress] 33/38: Use Java Objects class

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 fe2cb6a8ecb9e29363a3e2290158b29b59d495e5
Author: Gary Gregory <ga...@gmail.com>
AuthorDate: Thu Dec 8 11:12:36 2022 -0500

    Use Java Objects class
    
    Use final parameter
---
 .../compress/harmony/unpack200/bytecode/SourceFileAttribute.java   | 7 ++-----
 1 file changed, 2 insertions(+), 5 deletions(-)

diff --git a/src/main/java/org/apache/commons/compress/harmony/unpack200/bytecode/SourceFileAttribute.java b/src/main/java/org/apache/commons/compress/harmony/unpack200/bytecode/SourceFileAttribute.java
index a9b995e8..ffbaa2c1 100644
--- a/src/main/java/org/apache/commons/compress/harmony/unpack200/bytecode/SourceFileAttribute.java
+++ b/src/main/java/org/apache/commons/compress/harmony/unpack200/bytecode/SourceFileAttribute.java
@@ -18,6 +18,7 @@ package org.apache.commons.compress.harmony.unpack200.bytecode;
 
 import java.io.DataOutputStream;
 import java.io.IOException;
+import java.util.Objects;
 
 /**
  * Source file class file attribute
@@ -49,11 +50,7 @@ public class SourceFileAttribute extends Attribute {
             return false;
         }
         final SourceFileAttribute other = (SourceFileAttribute) obj;
-        if (name == null) {
-            if (other.name != null) {
-                return false;
-            }
-        } else if (!name.equals(other.name)) {
+        if (!Objects.equals(name, other.name)) {
             return false;
         }
         return true;


[commons-compress] 08/38: Remove trailing whitespace

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 acf8db3623871ced1cad25d5cfb32269ffcc1056
Author: Gary Gregory <ga...@gmail.com>
AuthorDate: Thu Dec 8 11:04:29 2022 -0500

    Remove trailing whitespace
---
 src/main/java/org/apache/commons/compress/harmony/pack200/BcBands.java | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/main/java/org/apache/commons/compress/harmony/pack200/BcBands.java b/src/main/java/org/apache/commons/compress/harmony/pack200/BcBands.java
index 1b5fec94..71bbe7e3 100644
--- a/src/main/java/org/apache/commons/compress/harmony/pack200/BcBands.java
+++ b/src/main/java/org/apache/commons/compress/harmony/pack200/BcBands.java
@@ -46,7 +46,7 @@ public class BcBands extends BandSet {
     private final IntList bcByte = new IntList();
     private final IntList bcShort = new IntList();
     private final IntList bcLocal = new IntList();
-    
+
     // Integers and/or Labels?
     private final List bcLabel = new ArrayList();
     private final List<CPInt> bcIntref = new ArrayList<>();


[commons-compress] 12/38: Convert cascading if/else to switch

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 94a4ad22283d1a3c1753b73d3483114a238a1e76
Author: Gary Gregory <ga...@gmail.com>
AuthorDate: Thu Dec 8 11:05:31 2022 -0500

    Convert cascading if/else to switch
---
 .../compress/harmony/pack200/ClassBands.java       | 29 ++++++++++++++--------
 1 file changed, 19 insertions(+), 10 deletions(-)

diff --git a/src/main/java/org/apache/commons/compress/harmony/pack200/ClassBands.java b/src/main/java/org/apache/commons/compress/harmony/pack200/ClassBands.java
index 593c59bd..dfc026a7 100644
--- a/src/main/java/org/apache/commons/compress/harmony/pack200/ClassBands.java
+++ b/src/main/java/org/apache/commons/compress/harmony/pack200/ClassBands.java
@@ -294,22 +294,31 @@ public class ClassBands extends BandSet {
 			final int numHandlers = codeHandlerCount.get(i - removed);
 			final int maxLocals = codeMaxLocals.get(i - removed);
 			final int maxStack = codeMaxStack.get(i - removed);
-			if (numHandlers == 0) {
-				final int header = maxLocals * 12 + maxStack + 1;
-				if (header < 145 && maxStack < 12) {
+			switch (numHandlers) {
+            case 0: {
+                final int header = maxLocals * 12 + maxStack + 1;
+                if (header < 145 && maxStack < 12) {
 					codeHeaders[i] = header;
 				}
-			} else if (numHandlers == 1) {
-				final int header = maxLocals * 8 + maxStack + 145;
-				if (header < 209 && maxStack < 8) {
+                break;
+            }
+            case 1: {
+                final int header = maxLocals * 8 + maxStack + 145;
+                if (header < 209 && maxStack < 8) {
 					codeHeaders[i] = header;
 				}
-			} else if (numHandlers == 2) {
-				final int header = maxLocals * 7 + maxStack + 209;
-				if (header < 256 && maxStack < 7) {
+                break;
+            }
+            case 2: {
+                final int header = maxLocals * 7 + maxStack + 209;
+                if (header < 256 && maxStack < 7) {
 					codeHeaders[i] = header;
 				}
-			}
+                break;
+            }
+            default:
+                break;
+            }
 			if (codeHeaders[i] != 0) { // Remove the redundant values from
 										// codeHandlerCount, codeMaxLocals and
 										// codeMaxStack


[commons-compress] 22/38: Use simple array initialization

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 1263e7ca00a6c0593804c0ad7c979752ef515ca1
Author: Gary Gregory <ga...@gmail.com>
AuthorDate: Thu Dec 8 11:08:30 2022 -0500

    Use simple array initialization
---
 .../compress/compressors/snappy/FramedSnappyCompressorInputStream.java  | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

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 a2e567f9..c55b7451 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
@@ -55,7 +55,7 @@ public class FramedSnappyCompressorInputStream extends CompressorInputStream
     private static final int MAX_SKIPPABLE_TYPE = 0xfd;
 
     // used by FramedSnappyCompressorOutputStream as well
-    static final byte[] SZ_SIGNATURE = new byte[] { //NOSONAR
+    static final byte[] SZ_SIGNATURE = { //NOSONAR
         (byte) STREAM_IDENTIFIER_TYPE, // tag
         6, 0, 0, // length
         's', 'N', 'a', 'P', 'p', 'Y'


[commons-compress] 24/38: Use simple array initialization

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 f07a2fea9a6161b25e3f77e6ea3f5b347b8366d7
Author: Gary Gregory <ga...@gmail.com>
AuthorDate: Thu Dec 8 11:08:52 2022 -0500

    Use simple array initialization
---
 .../java/org/apache/commons/compress/harmony/unpack200/IcTuple.java     | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/main/java/org/apache/commons/compress/harmony/unpack200/IcTuple.java b/src/main/java/org/apache/commons/compress/harmony/unpack200/IcTuple.java
index 0ee5fc20..b8610e65 100644
--- a/src/main/java/org/apache/commons/compress/harmony/unpack200/IcTuple.java
+++ b/src/main/java/org/apache/commons/compress/harmony/unpack200/IcTuple.java
@@ -29,7 +29,7 @@ import java.util.List;
  */
 public class IcTuple {
 
-    private static final String[] EMPTY_STRING_ARRAY = new String[] {};
+    private static final String[] EMPTY_STRING_ARRAY = {};
     private final int cIndex;
     private final int c2Index;
     private final int nIndex;


[commons-compress] 30/38: Remove redundant call to super()

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 40d6d6c855078ae844b43a271ffbdbf5da593920
Author: Gary Gregory <ga...@gmail.com>
AuthorDate: Thu Dec 8 11:11:20 2022 -0500

    Remove redundant call to super()
---
 .../compress/harmony/unpack200/SegmentConstantPoolArrayCache.java        | 1 -
 1 file changed, 1 deletion(-)

diff --git a/src/main/java/org/apache/commons/compress/harmony/unpack200/SegmentConstantPoolArrayCache.java b/src/main/java/org/apache/commons/compress/harmony/unpack200/SegmentConstantPoolArrayCache.java
index 264a994a..f3b33d17 100644
--- a/src/main/java/org/apache/commons/compress/harmony/unpack200/SegmentConstantPoolArrayCache.java
+++ b/src/main/java/org/apache/commons/compress/harmony/unpack200/SegmentConstantPoolArrayCache.java
@@ -106,7 +106,6 @@ public class SegmentConstantPoolArrayCache {
         HashMap<String, List<Integer>> primaryTable;
 
         public CachedArray(final String[] array) {
-            super();
             this.primaryArray = array;
             this.lastKnownSize = array.length;
             this.primaryTable = new HashMap<>(lastKnownSize);


[commons-compress] 31/38: Make private class static

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 36f2d6e85b7304343d9bdebda049c434bb3dc6ae
Author: Gary Gregory <ga...@gmail.com>
AuthorDate: Thu Dec 8 11:11:37 2022 -0500

    Make private class static
---
 .../java/org/apache/commons/compress/harmony/pack200/SegmentHeader.java | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/main/java/org/apache/commons/compress/harmony/pack200/SegmentHeader.java b/src/main/java/org/apache/commons/compress/harmony/pack200/SegmentHeader.java
index 5c1ca486..676b3c50 100644
--- a/src/main/java/org/apache/commons/compress/harmony/pack200/SegmentHeader.java
+++ b/src/main/java/org/apache/commons/compress/harmony/pack200/SegmentHeader.java
@@ -292,7 +292,7 @@ public class SegmentHeader extends BandSet {
     /**
      * Counter for major/minor class file numbers so we can work out the default
      */
-    private class Counter {
+    private static class Counter {
 
         private final int[] objs = new int[8];
         private final int[] counts = new int[8];


[commons-compress] 35/38: Remove trailing whitespace

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 31af637370776c184d2753b8a87cf646d4c33a92
Author: Gary Gregory <ga...@gmail.com>
AuthorDate: Thu Dec 8 11:13:47 2022 -0500

    Remove trailing whitespace
---
 .../apache/commons/compress/archivers/tar/TarConstants.java  | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/src/main/java/org/apache/commons/compress/archivers/tar/TarConstants.java b/src/main/java/org/apache/commons/compress/archivers/tar/TarConstants.java
index 1b082cdd..cc429da8 100644
--- a/src/main/java/org/apache/commons/compress/archivers/tar/TarConstants.java
+++ b/src/main/java/org/apache/commons/compress/archivers/tar/TarConstants.java
@@ -80,7 +80,7 @@ public interface TarConstants {
 
     /**
      * Offset of the checksum field within header record.
-     * 
+     *
      * @since 1.5
      */
     int CHKSUM_OFFSET = 148;
@@ -185,28 +185,28 @@ public interface TarConstants {
 
     /**
      * The length of offset in struct sparse
-     * 
+     *
      * @since 1.20
      */
     int SPARSE_OFFSET_LEN = 12;
 
     /**
      * The length of numbytes in struct sparse
-     * 
+     *
      * @since 1.20
      */
     int SPARSE_NUMBYTES_LEN = 12;
 
     /**
      * The number of sparse headers in an old GNU header
-     * 
+     *
      * @since 1.20
      */
     int SPARSE_HEADERS_IN_OLDGNU_HEADER = 4;
 
     /**
      * The number of sparse headers in an extension header
-     * 
+     *
      * @since 1.20
      */
     int SPARSE_HEADERS_IN_EXTENSION_HEADER = 21;
@@ -332,7 +332,7 @@ public interface TarConstants {
      * The magic tag representing a GNU tar archive.
      */
     String MAGIC_GNU = "ustar ";
-    
+
     /**
      * One of two two possible GNU versions
      */


[commons-compress] 27/38: Convert cascading if/else to switch

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 37c2c30de9e708fbbf9762ac4817e7d5b18885cc
Author: Gary Gregory <ga...@gmail.com>
AuthorDate: Thu Dec 8 11:10:18 2022 -0500

    Convert cascading if/else to switch
    
    Make private class static
---
 .../compress/harmony/unpack200/NewAttributeBands.java      | 14 ++++++++++----
 1 file changed, 10 insertions(+), 4 deletions(-)

diff --git a/src/main/java/org/apache/commons/compress/harmony/unpack200/NewAttributeBands.java b/src/main/java/org/apache/commons/compress/harmony/unpack200/NewAttributeBands.java
index 2bcca885..4e68e144 100644
--- a/src/main/java/org/apache/commons/compress/harmony/unpack200/NewAttributeBands.java
+++ b/src/main/java/org/apache/commons/compress/harmony/unpack200/NewAttributeBands.java
@@ -341,7 +341,7 @@ public class NewAttributeBands extends BandSet {
 
     }
 
-    private abstract class LayoutElement implements AttributeLayoutElement {
+    private abstract static class LayoutElement implements AttributeLayoutElement {
 
         protected int getLength(final char uint_type) {
             int length = 0;
@@ -407,12 +407,18 @@ public class NewAttributeBands extends BandSet {
             } else if (tag.startsWith("OS")) {
                 final char uint_type = tag.substring(2).toCharArray()[0];
                 final int length = getLength(uint_type);
-                if (length == 1) {
+                switch (length) {
+                case 1:
                     value = (byte) value;
-                } else if (length == 2) {
+                    break;
+                case 2:
                     value = (short) value;
-                } else if (length == 4) {
+                    break;
+                case 4:
                     value = value;
+                    break;
+                default:
+                    break;
                 }
                 attribute.addBCLength(length, value);
             } else if (tag.startsWith("O")) {


[commons-compress] 21/38: Use simple array initialization

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 c3c19e567b25dd69d81d69b70729a3e4cf3f36de
Author: Gary Gregory <ga...@gmail.com>
AuthorDate: Thu Dec 8 11:08:11 2022 -0500

    Use simple array initialization
---
 .../compress/compressors/lz4/FramedLZ4CompressorInputStream.java      | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

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 85efd9e9..16042ec7 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
@@ -43,10 +43,10 @@ public class FramedLZ4CompressorInputStream extends CompressorInputStream
     implements InputStreamStatistics {
 
     // used by FramedLZ4CompressorOutputStream as well
-    static final byte[] LZ4_SIGNATURE = new byte[] { //NOSONAR
+    static final byte[] LZ4_SIGNATURE = { //NOSONAR
         4, 0x22, 0x4d, 0x18
     };
-    private static final byte[] SKIPPABLE_FRAME_TRAILER = new byte[] {
+    private static final byte[] SKIPPABLE_FRAME_TRAILER = {
         0x2a, 0x4d, 0x18
     };
     private static final byte SKIPPABLE_FRAME_PREFIX_BYTE_MASK = 0x50;


[commons-compress] 01/38: Use simple array initialization

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 8895dab3cca9e40ed2dbc25ff9387627dd0fa5e2
Author: Gary Gregory <ga...@gmail.com>
AuthorDate: Thu Dec 8 11:01:53 2022 -0500

    Use simple array initialization
---
 src/main/java/org/apache/commons/compress/archivers/sevenz/Archive.java | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/main/java/org/apache/commons/compress/archivers/sevenz/Archive.java b/src/main/java/org/apache/commons/compress/archivers/sevenz/Archive.java
index 7d3d86ad..429ca86c 100644
--- a/src/main/java/org/apache/commons/compress/archivers/sevenz/Archive.java
+++ b/src/main/java/org/apache/commons/compress/archivers/sevenz/Archive.java
@@ -23,7 +23,7 @@ class Archive {
     /// Offset from beginning of file + SIGNATURE_HEADER_SIZE to packed streams.
     long packPos;
     /// Size of each packed stream.
-    long[] packSizes = new long[0];
+    long[] packSizes = {};
     /// Whether each particular packed streams has a CRC.
     BitSet packCrcsDefined;
     /// CRCs for each packed stream, valid only if that packed stream has one.


[commons-compress] 04/38: Use final parameter

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 3fd944d5790080c66ed5f9a054f5cbd9d1dcd2a5
Author: Gary Gregory <ga...@gmail.com>
AuthorDate: Thu Dec 8 11:02:49 2022 -0500

    Use final parameter
---
 .../commons/compress/utils/BoundedSeekableByteChannelInputStream.java   | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/main/java/org/apache/commons/compress/utils/BoundedSeekableByteChannelInputStream.java b/src/main/java/org/apache/commons/compress/utils/BoundedSeekableByteChannelInputStream.java
index 75d352e8..12896e11 100644
--- a/src/main/java/org/apache/commons/compress/utils/BoundedSeekableByteChannelInputStream.java
+++ b/src/main/java/org/apache/commons/compress/utils/BoundedSeekableByteChannelInputStream.java
@@ -45,7 +45,7 @@ public class BoundedSeekableByteChannelInputStream extends BoundedArchiveInputSt
     }
 
     @Override
-    protected int read(long pos, ByteBuffer buf) throws IOException {
+    protected int read(final long pos, final ByteBuffer buf) throws IOException {
         int read;
         synchronized (channel) {
             channel.position(pos);


[commons-compress] 16/38: Use Java Objects class

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 189b4f8e0cd979a05e04c818f6b139328980e50b
Author: Gary Gregory <ga...@gmail.com>
AuthorDate: Thu Dec 8 11:06:55 2022 -0500

    Use Java Objects class
---
 .../compress/harmony/unpack200/bytecode/CPFieldRef.java     | 13 +++----------
 1 file changed, 3 insertions(+), 10 deletions(-)

diff --git a/src/main/java/org/apache/commons/compress/harmony/unpack200/bytecode/CPFieldRef.java b/src/main/java/org/apache/commons/compress/harmony/unpack200/bytecode/CPFieldRef.java
index 6d219511..3a807b0c 100644
--- a/src/main/java/org/apache/commons/compress/harmony/unpack200/bytecode/CPFieldRef.java
+++ b/src/main/java/org/apache/commons/compress/harmony/unpack200/bytecode/CPFieldRef.java
@@ -18,6 +18,7 @@ package org.apache.commons.compress.harmony.unpack200.bytecode;
 
 import java.io.DataOutputStream;
 import java.io.IOException;
+import java.util.Objects;
 
 /**
  * Field reference constant pool entry.
@@ -90,18 +91,10 @@ public class CPFieldRef extends ConstantPoolEntry {
             return false;
         }
         final CPFieldRef other = (CPFieldRef) obj;
-        if (className == null) {
-            if (other.className != null) {
-                return false;
-            }
-        } else if (!className.equals(other.className)) {
+        if (!Objects.equals(className, other.className)) {
             return false;
         }
-        if (nameAndType == null) {
-            if (other.nameAndType != null) {
-                return false;
-            }
-        } else if (!nameAndType.equals(other.nameAndType)) {
+        if (!Objects.equals(nameAndType, other.nameAndType)) {
             return false;
         }
         return true;


[commons-compress] 05/38: Use final parameter

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 7d2a465eb0ec7cb8828b426ffc9f2919e94dfa8e
Author: Gary Gregory <ga...@gmail.com>
AuthorDate: Thu Dec 8 11:03:02 2022 -0500

    Use final parameter
---
 .../org/apache/commons/compress/archivers/arj/ArjArchiveEntry.java    | 4 ++--
 .../org/apache/commons/compress/utils/BoundedArchiveInputStream.java  | 2 +-
 2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/src/main/java/org/apache/commons/compress/archivers/arj/ArjArchiveEntry.java b/src/main/java/org/apache/commons/compress/archivers/arj/ArjArchiveEntry.java
index 6b742c89..e9b9fa7f 100644
--- a/src/main/java/org/apache/commons/compress/archivers/arj/ArjArchiveEntry.java
+++ b/src/main/java/org/apache/commons/compress/archivers/arj/ArjArchiveEntry.java
@@ -51,8 +51,8 @@ public class ArjArchiveEntry implements ArchiveEntry {
     @Override
     public String getName() {
         if ((localFileHeader.arjFlags & LocalFileHeader.Flags.PATHSYM) != 0) {
-            return localFileHeader.name.replaceAll("/",
-                    Matcher.quoteReplacement(File.separator));
+            return localFileHeader.name.replace("/",
+                    File.separator);
         }
         return localFileHeader.name;
     }
diff --git a/src/main/java/org/apache/commons/compress/utils/BoundedArchiveInputStream.java b/src/main/java/org/apache/commons/compress/utils/BoundedArchiveInputStream.java
index a72aa151..37d90820 100644
--- a/src/main/java/org/apache/commons/compress/utils/BoundedArchiveInputStream.java
+++ b/src/main/java/org/apache/commons/compress/utils/BoundedArchiveInputStream.java
@@ -66,7 +66,7 @@ public abstract class BoundedArchiveInputStream extends InputStream {
     }
 
     @Override
-    public synchronized int read(final byte[] b, final int off, int len) throws IOException {
+    public synchronized int read(final byte[] b, final int off, final int len) throws IOException {
         if (loc >= end) {
             return -1;
         }


[commons-compress] 15/38: Use Java Objects class

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 9752f9d1d89f361ebf539c1cba736f7dc5faa0b6
Author: Gary Gregory <ga...@gmail.com>
AuthorDate: Thu Dec 8 11:06:41 2022 -0500

    Use Java Objects class
---
 .../compress/harmony/unpack200/bytecode/CPConstant.java       | 11 ++---------
 1 file changed, 2 insertions(+), 9 deletions(-)

diff --git a/src/main/java/org/apache/commons/compress/harmony/unpack200/bytecode/CPConstant.java b/src/main/java/org/apache/commons/compress/harmony/unpack200/bytecode/CPConstant.java
index e94df933..5b6d39f2 100644
--- a/src/main/java/org/apache/commons/compress/harmony/unpack200/bytecode/CPConstant.java
+++ b/src/main/java/org/apache/commons/compress/harmony/unpack200/bytecode/CPConstant.java
@@ -50,11 +50,7 @@ public abstract class CPConstant extends ConstantPoolEntry {
             return false;
         }
         final CPConstant other = (CPConstant) obj;
-        if (value == null) {
-            if (other.value != null) {
-                return false;
-            }
-        } else if (!value.equals(other.value)) {
+        if (!Objects.equals(value, other.value)) {
             return false;
         }
         return true;
@@ -62,10 +58,7 @@ public abstract class CPConstant extends ConstantPoolEntry {
 
     @Override
     public int hashCode() {
-        final int PRIME = 31;
-        int result = 1;
-        result = PRIME * result + ((value == null) ? 0 : value.hashCode());
-        return result;
+        return Objects.hash(value);
     }
 
     protected Object getValue() {


[commons-compress] 32/38: Use simple array initialization

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 6abbaeac0d3b9fd4d64db0712c18606984a69a77
Author: Gary Gregory <ga...@gmail.com>
AuthorDate: Thu Dec 8 11:11:59 2022 -0500

    Use simple array initialization
---
 .../apache/commons/compress/archivers/sevenz/SevenZArchiveEntry.java  | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/src/main/java/org/apache/commons/compress/archivers/sevenz/SevenZArchiveEntry.java b/src/main/java/org/apache/commons/compress/archivers/sevenz/SevenZArchiveEntry.java
index e9e73313..356628dd 100644
--- a/src/main/java/org/apache/commons/compress/archivers/sevenz/SevenZArchiveEntry.java
+++ b/src/main/java/org/apache/commons/compress/archivers/sevenz/SevenZArchiveEntry.java
@@ -35,7 +35,7 @@ import org.apache.commons.compress.utils.TimeUtils;
  * @since 1.6
  */
 public class SevenZArchiveEntry implements ArchiveEntry {
-    static final SevenZArchiveEntry[] EMPTY_SEVEN_Z_ARCHIVE_ENTRY_ARRAY = new SevenZArchiveEntry[0];
+    static final SevenZArchiveEntry[] EMPTY_SEVEN_Z_ARCHIVE_ENTRY_ARRAY = {};
     /**
      * Converts Java time to NTFS time.
      * @param date the Java time
@@ -493,7 +493,7 @@ public class SevenZArchiveEntry implements ArchiveEntry {
      * @param methods the methods to use for the content
      * @since 1.22
      */
-    public void setContentMethods(SevenZMethodConfiguration... methods) {
+    public void setContentMethods(final SevenZMethodConfiguration... methods) {
         setContentMethods(Arrays.asList(methods));
     }
 


[commons-compress] 25/38: Remove trailing whitespace

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 c6314a9fe830025317e7102ffacc94c9e7e18fcf
Author: Gary Gregory <ga...@gmail.com>
AuthorDate: Thu Dec 8 11:08:57 2022 -0500

    Remove trailing whitespace
---
 src/main/java/org/apache/commons/compress/archivers/Lister.java | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/main/java/org/apache/commons/compress/archivers/Lister.java b/src/main/java/org/apache/commons/compress/archivers/Lister.java
index b709cbb5..55524f54 100644
--- a/src/main/java/org/apache/commons/compress/archivers/Lister.java
+++ b/src/main/java/org/apache/commons/compress/archivers/Lister.java
@@ -50,7 +50,7 @@ public final class Lister {
      * <p>
      * The optional second argument defines the archive type, in case the format is not recognized.
      * </p>
-     * 
+     *
      * @param args name of the archive and optional argument archive type.
      * @throws ArchiveException Archiver related Exception.
      * @throws IOException an I/O exception.


[commons-compress] 10/38: Remove trailing whitespace

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 dd879752e8a448573a95dbd3462d4f0058095500
Author: Gary Gregory <ga...@gmail.com>
AuthorDate: Thu Dec 8 11:05:06 2022 -0500

    Remove trailing whitespace
---
 .../lz4/BlockLZ4CompressorOutputStream.java        | 26 +++++++++++-----------
 1 file changed, 13 insertions(+), 13 deletions(-)

diff --git a/src/main/java/org/apache/commons/compress/compressors/lz4/BlockLZ4CompressorOutputStream.java b/src/main/java/org/apache/commons/compress/compressors/lz4/BlockLZ4CompressorOutputStream.java
index 61f0453e..1701eebc 100644
--- a/src/main/java/org/apache/commons/compress/compressors/lz4/BlockLZ4CompressorOutputStream.java
+++ b/src/main/java/org/apache/commons/compress/compressors/lz4/BlockLZ4CompressorOutputStream.java
@@ -415,14 +415,14 @@ public class BlockLZ4CompressorOutputStream extends CompressorOutputStream {
         private void prependLiteral(final byte[] data) {
             literals.addFirst(data);
         }
-        
+
         byte[] addLiteral(final LZ77Compressor.LiteralBlock block) {
             final byte[] copy = Arrays.copyOfRange(block.getData(), block.getOffset(),
                 block.getOffset() + block.getLength());
             literals.add(copy);
             return copy;
         }
-        
+
         void setBackReference(final LZ77Compressor.BackReference block) {
             if (hasBackReference()) {
                 throw new IllegalStateException();
@@ -430,24 +430,24 @@ public class BlockLZ4CompressorOutputStream extends CompressorOutputStream {
             brOffset = block.getOffset();
             brLength = block.getLength();
         }
-        
+
         boolean hasBackReference() {
             return brOffset > 0;
         }
-        
+
         boolean canBeWritten(final int lengthOfBlocksAfterThisPair) {
             return hasBackReference()
                 && lengthOfBlocksAfterThisPair >= MIN_OFFSET_OF_LAST_BACK_REFERENCE + MIN_BACK_REFERENCE_LENGTH;
         }
-        
+
         int length() {
             return literalLength() + brLength;
         }
-        
+
         private boolean hasBeenWritten() {
             return written;
         }
-        
+
         void writeTo(final OutputStream out) throws IOException {
             final int litLength = literalLength();
             out.write(lengths(litLength, brLength));
@@ -466,17 +466,17 @@ public class BlockLZ4CompressorOutputStream extends CompressorOutputStream {
             }
             written = true;
         }
-        
+
         private int literalLength() {
             return literals.stream().mapToInt(b -> b.length).sum();
         }
-        
+
         private static int lengths(final int litLength, final int brLength) {
             final int l = Math.min(litLength, 15);
             final int br = brLength < 4 ? 0 : (brLength < 19 ? brLength - 4 : 15);
             return (l << BlockLZ4CompressorInputStream.SIZE_BITS) | br;
         }
-        
+
         private static void writeLength(int length, final OutputStream out) throws IOException {
             while (length >= 255) {
                 out.write(255);
@@ -484,18 +484,18 @@ public class BlockLZ4CompressorOutputStream extends CompressorOutputStream {
             }
             out.write(length);
         }
-        
+
         private int backReferenceLength() {
             return brLength;
         }
-        
+
         private void prependTo(final Pair other) {
             final Iterator<byte[]> listBackwards = literals.descendingIterator();
             while (listBackwards.hasNext()) {
                 other.prependLiteral(listBackwards.next());
             }
         }
-        
+
         private Pair splitWithNewBackReferenceLengthOf(final int newBackReferenceLength) {
             final Pair p = new Pair();
             p.literals.addAll(literals);


[commons-compress] 06/38: Use Java Objects class

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 f4021b0088f978dc728aeabc8566bf88ddeb8b96
Author: Gary Gregory <ga...@gmail.com>
AuthorDate: Thu Dec 8 11:03:56 2022 -0500

    Use Java Objects class
---
 .../compress/harmony/unpack200/bytecode/Attribute.java       | 12 +++---------
 1 file changed, 3 insertions(+), 9 deletions(-)

diff --git a/src/main/java/org/apache/commons/compress/harmony/unpack200/bytecode/Attribute.java b/src/main/java/org/apache/commons/compress/harmony/unpack200/bytecode/Attribute.java
index f8327ba0..af215551 100644
--- a/src/main/java/org/apache/commons/compress/harmony/unpack200/bytecode/Attribute.java
+++ b/src/main/java/org/apache/commons/compress/harmony/unpack200/bytecode/Attribute.java
@@ -18,6 +18,7 @@ package org.apache.commons.compress.harmony.unpack200.bytecode;
 
 import java.io.DataOutputStream;
 import java.io.IOException;
+import java.util.Objects;
 
 /**
  * Abstract superclass for class file attributes
@@ -51,11 +52,7 @@ public abstract class Attribute extends ClassFileEntry {
             return false;
         }
         final Attribute other = (Attribute) obj;
-        if (attributeName == null) {
-            if (other.attributeName != null) {
-                return false;
-            }
-        } else if (!attributeName.equals(other.attributeName)) {
+        if (!Objects.equals(attributeName, other.attributeName)) {
             return false;
         }
         return true;
@@ -104,10 +101,7 @@ public abstract class Attribute extends ClassFileEntry {
 
     @Override
     public int hashCode() {
-        final int PRIME = 31;
-        int result = 1;
-        result = PRIME * result + ((attributeName == null) ? 0 : attributeName.hashCode());
-        return result;
+        return Objects.hash(attributeName);
     }
 
     @Override


[commons-compress] 09/38: Convert cascading if/else to switch

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 f5ee439042e309980d62bb3a338db18b87775445
Author: Gary Gregory <ga...@gmail.com>
AuthorDate: Thu Dec 8 11:04:54 2022 -0500

    Convert cascading if/else to switch
---
 .../apache/commons/compress/harmony/pack200/BHSDCodec.java   | 12 ++++++++----
 1 file changed, 8 insertions(+), 4 deletions(-)

diff --git a/src/main/java/org/apache/commons/compress/harmony/pack200/BHSDCodec.java b/src/main/java/org/apache/commons/compress/harmony/pack200/BHSDCodec.java
index ff1d99bd..c03cf7a6 100644
--- a/src/main/java/org/apache/commons/compress/harmony/pack200/BHSDCodec.java
+++ b/src/main/java/org/apache/commons/compress/harmony/pack200/BHSDCodec.java
@@ -381,13 +381,17 @@ public final class BHSDCodec extends Codec {
             final BHSDCodec bh0 = new BHSDCodec(b, h);
             return bh0.largest();
         }
-        if (s == 0) {
+        switch (s) {
+        case 0:
             result = cardinality() - 1;
-        } else if (s == 1) {
+            break;
+        case 1:
             result = cardinality() / 2 - 1;
-        } else if (s == 2) {
+            break;
+        case 2:
             result = (3L * cardinality()) / 4 - 1;
-        } else {
+            break;
+        default:
             throw new Error("Unknown s value");
         }
         return Math.min((s == 0 ? ((long) Integer.MAX_VALUE) << 1 : Integer.MAX_VALUE) - 1, result);


[commons-compress] 38/38: Use final parameter

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 d5949db4d2ba990cfcaf69c173dfa679366610a3
Author: Gary Gregory <ga...@gmail.com>
AuthorDate: Thu Dec 8 11:15:23 2022 -0500

    Use final parameter
---
 .../org/apache/commons/compress/archivers/zip/ZipEncodingHelper.java    | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/main/java/org/apache/commons/compress/archivers/zip/ZipEncodingHelper.java b/src/main/java/org/apache/commons/compress/archivers/zip/ZipEncodingHelper.java
index 3902f174..e9b4faab 100644
--- a/src/main/java/org/apache/commons/compress/archivers/zip/ZipEncodingHelper.java
+++ b/src/main/java/org/apache/commons/compress/archivers/zip/ZipEncodingHelper.java
@@ -69,7 +69,7 @@ public abstract class ZipEncodingHelper {
      *
      * @param charsetName If the given name is null, then check the platform's default encoding.
      */
-    static boolean isUTF8(String charsetName) {
+    static boolean isUTF8(final String charsetName) {
         final String actual = charsetName != null ? charsetName : Charset.defaultCharset().name();
         if (UTF_8.name().equalsIgnoreCase(actual)) {
             return true;


[commons-compress] 02/38: Remove trailing whitespace

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 bb90215e6313a1e4c32d5aeba96791c64373b1ea
Author: Gary Gregory <ga...@gmail.com>
AuthorDate: Thu Dec 8 11:02:11 2022 -0500

    Remove trailing whitespace
---
 .../org/apache/commons/compress/archivers/ArchiveStreamFactory.java     | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/main/java/org/apache/commons/compress/archivers/ArchiveStreamFactory.java b/src/main/java/org/apache/commons/compress/archivers/ArchiveStreamFactory.java
index 0b34a6a4..fcc9f9e9 100644
--- a/src/main/java/org/apache/commons/compress/archivers/ArchiveStreamFactory.java
+++ b/src/main/java/org/apache/commons/compress/archivers/ArchiveStreamFactory.java
@@ -208,7 +208,7 @@ public class ArchiveStreamFactory implements ArchiveStreamProvider {
     private static Iterable<ArchiveStreamProvider> archiveStreamProviderIterable() {
         return ServiceLoader.load(ArchiveStreamProvider.class, ClassLoader.getSystemClassLoader());
     }
-    
+
     private static String toKey(final String name) {
         return name.toUpperCase(Locale.ROOT);
     }


[commons-compress] 20/38: Use simple array initialization

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 12c311a89502bb2b0e80ae73e366a161292d42d3
Author: Gary Gregory <ga...@gmail.com>
AuthorDate: Thu Dec 8 11:07:56 2022 -0500

    Use simple array initialization
---
 src/main/java/org/apache/commons/compress/archivers/sevenz/Folder.java | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/main/java/org/apache/commons/compress/archivers/sevenz/Folder.java b/src/main/java/org/apache/commons/compress/archivers/sevenz/Folder.java
index 26421385..cfa7e4b3 100644
--- a/src/main/java/org/apache/commons/compress/archivers/sevenz/Folder.java
+++ b/src/main/java/org/apache/commons/compress/archivers/sevenz/Folder.java
@@ -46,7 +46,7 @@ class Folder {
     /// output streams and the number of non-empty files in this
     /// folder.
     int numUnpackSubStreams;
-    static final Folder[] EMPTY_FOLDER_ARRAY = new Folder[0];
+    static final Folder[] EMPTY_FOLDER_ARRAY = {};
 
     /**
      * Sorts Coders using bind pairs.


[commons-compress] 19/38: Use simple array initialization

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 b4af7d3cc891b8f2ec5d31a79d690ce8d750636a
Author: Gary Gregory <ga...@gmail.com>
AuthorDate: Thu Dec 8 11:07:47 2022 -0500

    Use simple array initialization
---
 .../java/org/apache/commons/compress/archivers/zip/ExtraFieldUtils.java | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/main/java/org/apache/commons/compress/archivers/zip/ExtraFieldUtils.java b/src/main/java/org/apache/commons/compress/archivers/zip/ExtraFieldUtils.java
index 18b5151a..529ff914 100644
--- a/src/main/java/org/apache/commons/compress/archivers/zip/ExtraFieldUtils.java
+++ b/src/main/java/org/apache/commons/compress/archivers/zip/ExtraFieldUtils.java
@@ -417,5 +417,5 @@ public class ExtraFieldUtils {
 
     }
 
-    static final ZipExtraField[] EMPTY_ZIP_EXTRA_FIELD_ARRAY = new ZipExtraField[0];
+    static final ZipExtraField[] EMPTY_ZIP_EXTRA_FIELD_ARRAY = {};
 }


[commons-compress] 17/38: Remove trailing whitespace

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 09f1c972518cd1a38fdaae1890c114d755d1317b
Author: Gary Gregory <ga...@gmail.com>
AuthorDate: Thu Dec 8 11:07:22 2022 -0500

    Remove trailing whitespace
---
 .../java/org/apache/commons/compress/archivers/cpio/CpioConstants.java  | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/main/java/org/apache/commons/compress/archivers/cpio/CpioConstants.java b/src/main/java/org/apache/commons/compress/archivers/cpio/CpioConstants.java
index 148a34f2..f71ca32f 100644
--- a/src/main/java/org/apache/commons/compress/archivers/cpio/CpioConstants.java
+++ b/src/main/java/org/apache/commons/compress/archivers/cpio/CpioConstants.java
@@ -22,7 +22,7 @@ package org.apache.commons.compress.archivers.cpio;
  * All constants needed by CPIO.
  *
  * based on code from the jRPM project (jrpm.sourceforge.net)
- * 
+ *
  * http://www.opengroup.org/onlinepubs/9699919799/basedefs/cpio.h.html has a list of the C_xxx constants.
  *
  */