You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by bo...@apache.org on 2017/05/11 18:49:09 UTC

[1/3] commons-compress git commit: javadocs

Repository: commons-compress
Updated Branches:
  refs/heads/master 86fbbe288 -> 0daa8708d


javadocs


Project: http://git-wip-us.apache.org/repos/asf/commons-compress/repo
Commit: http://git-wip-us.apache.org/repos/asf/commons-compress/commit/e646770c
Tree: http://git-wip-us.apache.org/repos/asf/commons-compress/tree/e646770c
Diff: http://git-wip-us.apache.org/repos/asf/commons-compress/diff/e646770c

Branch: refs/heads/master
Commit: e646770cfbaf617eb9183d94ac5002f736218013
Parents: 86fbbe2
Author: Stefan Bodewig <bo...@apache.org>
Authored: Thu May 11 20:29:37 2017 +0200
Committer: Stefan Bodewig <bo...@apache.org>
Committed: Thu May 11 20:29:37 2017 +0200

----------------------------------------------------------------------
 .../brotli/BrotliCompressorInputStream.java     | 43 --------------------
 .../lz4/BlockLZ4CompressorOutputStream.java     |  1 +
 .../compressors/lz77support/Parameters.java     | 19 +++++++++
 .../snappy/SnappyCompressorOutputStream.java    |  1 +
 4 files changed, 21 insertions(+), 43 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/commons-compress/blob/e646770c/src/main/java/org/apache/commons/compress/compressors/brotli/BrotliCompressorInputStream.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/commons/compress/compressors/brotli/BrotliCompressorInputStream.java b/src/main/java/org/apache/commons/compress/compressors/brotli/BrotliCompressorInputStream.java
index 37b050a..135988d 100644
--- a/src/main/java/org/apache/commons/compress/compressors/brotli/BrotliCompressorInputStream.java
+++ b/src/main/java/org/apache/commons/compress/compressors/brotli/BrotliCompressorInputStream.java
@@ -37,80 +37,46 @@ public class BrotliCompressorInputStream extends CompressorInputStream {
         this.decIS = new org.brotli.dec.BrotliInputStream(in);
     }
 
-    /**
-     * @return
-     * @throws IOException
-     * @see java.io.InputStream#available()
-     */
     @Override
     public int available() throws IOException {
         return decIS.available();
     }
 
-    /**
-     * @throws IOException
-     * @see org.brotli.dec.BrotliInputStream#close()
-     */
     @Override
     public void close() throws IOException {
         decIS.close();
     }
 
-    /**
-     * @return
-     * @see java.lang.Object#hashCode()
-     */
     @Override
     public int hashCode() {
         return decIS.hashCode();
     }
 
-    /** {@inheritDoc} */
     @Override
     public int read(final byte[] b) throws IOException {
         return decIS.read(b);
     }
 
-    /**
-     * @param obj
-     * @return
-     * @see java.lang.Object#equals(java.lang.Object)
-     */
     @Override
     public boolean equals(final Object obj) {
         return decIS.equals(obj);
     }
 
-    /**
-     * @param n
-     * @return
-     * @throws IOException
-     * @see java.io.InputStream#skip(long)
-     */
     @Override
     public long skip(final long n) throws IOException {
         return decIS.skip(n);
     }
 
-    /**
-     * @param readlimit
-     * @see java.io.InputStream#mark(int)
-     */
     @Override
     public void mark(final int readlimit) {
         decIS.mark(readlimit);
     }
 
-    /**
-     * @return
-     * @see java.io.InputStream#markSupported()
-     */
     @Override
     public boolean markSupported() {
         return decIS.markSupported();
     }
 
-    /** {@inheritDoc} */
     @Override
     public int read() throws IOException {
         final int ret = decIS.read();
@@ -118,7 +84,6 @@ public class BrotliCompressorInputStream extends CompressorInputStream {
         return ret;
     }
 
-    /** {@inheritDoc} */
     @Override
     public int read(final byte[] buf, final int off, final int len) throws IOException {
         final int ret = decIS.read(buf, off, len);
@@ -126,19 +91,11 @@ public class BrotliCompressorInputStream extends CompressorInputStream {
         return ret;
     }
 
-    /**
-     * @return
-     * @see java.lang.Object#toString()
-     */
     @Override
     public String toString() {
         return decIS.toString();
     }
 
-    /**
-     * @throws IOException
-     * @see java.io.InputStream#reset()
-     */
     @Override
     public void reset() throws IOException {
         decIS.reset();

http://git-wip-us.apache.org/repos/asf/commons-compress/blob/e646770c/src/main/java/org/apache/commons/compress/compressors/lz4/BlockLZ4CompressorOutputStream.java
----------------------------------------------------------------------
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 96f7a92..9330ea8 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
@@ -401,6 +401,7 @@ public class BlockLZ4CompressorOutputStream extends CompressorOutputStream {
 
     /**
      * Returns a builder correctly configured for the LZ4 algorithm.
+     * @return a builder correctly configured for the LZ4 algorithm
      */
     public static Parameters.Builder createParameterBuilder() {
         int maxLen = BlockLZ4CompressorInputStream.WINDOW_SIZE - 1;

http://git-wip-us.apache.org/repos/asf/commons-compress/blob/e646770c/src/main/java/org/apache/commons/compress/compressors/lz77support/Parameters.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/commons/compress/compressors/lz77support/Parameters.java b/src/main/java/org/apache/commons/compress/compressors/lz77support/Parameters.java
index 5cdbae9..d61ff65 100644
--- a/src/main/java/org/apache/commons/compress/compressors/lz77support/Parameters.java
+++ b/src/main/java/org/apache/commons/compress/compressors/lz77support/Parameters.java
@@ -41,6 +41,7 @@ public final class Parameters {
      * determines the maximum offset a back-reference can take. Must
      * be a power of two.
      * @throws IllegalArgumentException if windowSize is not a power of two.
+     * @return a builder configured for the given window size
      */
     public static Builder builder(int windowSize) {
         return new Builder(windowSize);
@@ -82,6 +83,7 @@ public final class Parameters {
          * but bigger lengths can be configured.
          * @throws IllegalArgumentException if <code>windowSize</code>
          * is smaller than <code>minBackReferenceLength</code>.
+         * @return the builder
          */
         public Builder withMinBackReferenceLength(int minBackReferenceLength) {
             this.minBackReferenceLength = Math.max(TRUE_MIN_BACK_REFERENCE_LENGTH, minBackReferenceLength);
@@ -107,6 +109,7 @@ public final class Parameters {
          * <code>minBackReferenceLength</code> is interpreted as
          * <code>minBackReferenceLength</code>. <code>maxBackReferenceLength</code>
          * is capped at <code>windowSize - 1</code>.
+         * @return the builder
          */
         public Builder withMaxBackReferenceLength(int maxBackReferenceLength) {
             this.maxBackReferenceLength = maxBackReferenceLength < minBackReferenceLength ? minBackReferenceLength
@@ -126,6 +129,7 @@ public final class Parameters {
          * non-positive value as well as values bigger than
          * <code>windowSize - 1</code> are interpreted as <code>windowSize
          * - 1</code>.
+         * @return the builder
          */
         public Builder withMaxOffset(int maxOffset) {
             this.maxOffset = maxOffset < 1 ? windowSize - 1 : Math.min(maxOffset, windowSize - 1);
@@ -144,6 +148,7 @@ public final class Parameters {
          * block. Negative numbers and 0 as well as values bigger than
          * <code>windowSize</code> are interpreted as
          * <code>windowSize</code>.
+         * @return the builder
          */
         public Builder withMaxLiteralLength(int maxLiteralLength) {
             this.maxLiteralLength = maxLiteralLength < 1 ? windowSize
@@ -157,6 +162,8 @@ public final class Parameters {
          * <p>When a back-references if this size has been found, stop searching for longer back-references.</p>
          *
          * <p>This settings can be used to tune the tradeoff between compression speed and compression ratio.</p>
+         * @param niceLen the "nice length" of a back-reference
+         * @return the builder
          */
         public Builder withNiceBackReferenceLength(int niceLen) {
             niceBackReferenceLength = niceLen;
@@ -167,6 +174,8 @@ public final class Parameters {
          * Sets the maximum number of back-reference candidates that should be consulted.
          *
          * <p>This settings can be used to tune the tradeoff between compression speed and compression ratio.</p>
+         * @param maxCandidates maximum number of back-reference candidates
+         * @return the builder
          */
         public Builder withMaxNumberOfCandidates(int maxCandidates) {
             this.maxCandidates = maxCandidates;
@@ -180,6 +189,8 @@ public final class Parameters {
          * try to find a longer match for the next position.</p>
          *
          * <p>Lazy matching is enabled by default and disabled when tuning for speed.</p>
+         * @param lazy whether lazy matching should be performed
+         * @return the builder
          */
         public Builder withLazyMatching(boolean lazy) {
             lazyMatches = lazy;
@@ -191,6 +202,8 @@ public final class Parameters {
          *
          * <p>Even if lazy matching is enabled it will not be performed if the length of the back-reference found for
          * the current position is longer than this value.</p>
+         * @param threshold the threshold for lazy matching
+         * @return the builder
          */
         public Builder withLazyThreshold(int threshold) {
             lazyThreshold = threshold;
@@ -202,6 +215,7 @@ public final class Parameters {
          * compression speed at the cost of compression ratio.
          *
          * <p>Use this method after configuring "maximum back-reference length".</p>
+         * @return the builder
          */
         public Builder tunedForSpeed() {
             niceBackReferenceLength = Math.max(minBackReferenceLength, maxBackReferenceLength / 8);
@@ -216,6 +230,7 @@ public final class Parameters {
          * compression ratio at the cost of compression speed.
          *
          * <p>Use this method after configuring "maximum back-reference length".</p>
+         * @return the builder
          */
         public Builder tunedForCompressionRatio() {
             niceBackReferenceLength = lazyThreshold = maxBackReferenceLength;
@@ -298,6 +313,7 @@ public final class Parameters {
 
     /**
      * Gets the length of a back-reference that is considered nice enough to stop searching for longer ones.
+     * @return the length of a back-reference that is considered nice enough to stop searching
      */
     public int getNiceBackReferenceLength() {
         return niceBackReferenceLength;
@@ -305,6 +321,7 @@ public final class Parameters {
 
     /**
      * Gets the maximum number of back-reference candidates to consider.
+     * @return the maximum number of back-reference candidates to consider
      */
     public int getMaxCandidates() {
         return maxCandidates;
@@ -312,6 +329,7 @@ public final class Parameters {
 
     /**
      * Gets whether to perform lazy matching.
+     * @return whether to perform lazy matching
      */
     public boolean getLazyMatching() {
         return lazyMatching;
@@ -319,6 +337,7 @@ public final class Parameters {
 
     /**
      * Gets the threshold for lazy matching.
+     * @return the threshold for lazy matching
      */
     public int getLazyMatchingThreshold() {
         return lazyThreshold;

http://git-wip-us.apache.org/repos/asf/commons-compress/blob/e646770c/src/main/java/org/apache/commons/compress/compressors/snappy/SnappyCompressorOutputStream.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/commons/compress/compressors/snappy/SnappyCompressorOutputStream.java b/src/main/java/org/apache/commons/compress/compressors/snappy/SnappyCompressorOutputStream.java
index 5d24d37..5705bec 100644
--- a/src/main/java/org/apache/commons/compress/compressors/snappy/SnappyCompressorOutputStream.java
+++ b/src/main/java/org/apache/commons/compress/compressors/snappy/SnappyCompressorOutputStream.java
@@ -266,6 +266,7 @@ public class SnappyCompressorOutputStream extends CompressorOutputStream {
     /**
      * Returns a builder correctly configured for the Snappy algorithm using the gven block size.
      * @param blockSize the block size.
+     * @return a builder correctly configured for the Snappy algorithm using the gven block size
      */
     public static Parameters.Builder createParameterBuilder(int blockSize) {
         // the max offset and max literal length defined by the format


[2/3] commons-compress git commit: PMD findings

Posted by bo...@apache.org.
PMD findings


Project: http://git-wip-us.apache.org/repos/asf/commons-compress/repo
Commit: http://git-wip-us.apache.org/repos/asf/commons-compress/commit/591b9f97
Tree: http://git-wip-us.apache.org/repos/asf/commons-compress/tree/591b9f97
Diff: http://git-wip-us.apache.org/repos/asf/commons-compress/diff/591b9f97

Branch: refs/heads/master
Commit: 591b9f9795c6eaf782580327e82a70164a640d34
Parents: e646770
Author: Stefan Bodewig <bo...@apache.org>
Authored: Thu May 11 20:43:09 2017 +0200
Committer: Stefan Bodewig <bo...@apache.org>
Committed: Thu May 11 20:43:09 2017 +0200

----------------------------------------------------------------------
 .../apache/commons/compress/archivers/sevenz/SevenZFile.java   | 6 +++---
 .../compress/archivers/zip/ResourceAlignmentExtraField.java    | 3 ++-
 .../commons/compress/archivers/zip/ZipArchiveOutputStream.java | 2 +-
 .../compressors/brotli/BrotliCompressorInputStream.java        | 1 -
 .../compressors/lz4/BlockLZ4CompressorOutputStream.java        | 1 -
 .../commons/compress/compressors/lz77support/Parameters.java   | 2 +-
 6 files changed, 7 insertions(+), 8 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/commons-compress/blob/591b9f97/src/main/java/org/apache/commons/compress/archivers/sevenz/SevenZFile.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/commons/compress/archivers/sevenz/SevenZFile.java b/src/main/java/org/apache/commons/compress/archivers/sevenz/SevenZFile.java
index 9ad0746..e0de903 100644
--- a/src/main/java/org/apache/commons/compress/archivers/sevenz/SevenZFile.java
+++ b/src/main/java/org/apache/commons/compress/archivers/sevenz/SevenZFile.java
@@ -803,7 +803,7 @@ public class SevenZFile implements Closeable {
         int nonEmptyFileCounter = 0;
         int emptyFileCounter = 0;
         for (int i = 0; i < files.length; i++) {
-            files[i].setHasStream(isEmptyStream == null ? true : !isEmptyStream.get(i));
+            files[i].setHasStream(isEmptyStream == null || !isEmptyStream.get(i));
             if (files[i].hasStream()) {
                 files[i].setDirectory(false);
                 files[i].setAntiItem(false);
@@ -812,8 +812,8 @@ public class SevenZFile implements Closeable {
                 files[i].setSize(archive.subStreamsInfo.unpackSizes[nonEmptyFileCounter]);
                 ++nonEmptyFileCounter;
             } else {
-                files[i].setDirectory(isEmptyFile == null ? true : !isEmptyFile.get(emptyFileCounter));
-                files[i].setAntiItem(isAnti == null ? false : isAnti.get(emptyFileCounter));
+                files[i].setDirectory(isEmptyFile == null || !isEmptyFile.get(emptyFileCounter));
+                files[i].setAntiItem(isAnti != null && isAnti.get(emptyFileCounter));
                 files[i].setHasCrc(false);
                 files[i].setSize(0);
                 ++emptyFileCounter;

http://git-wip-us.apache.org/repos/asf/commons-compress/blob/591b9f97/src/main/java/org/apache/commons/compress/archivers/zip/ResourceAlignmentExtraField.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/commons/compress/archivers/zip/ResourceAlignmentExtraField.java b/src/main/java/org/apache/commons/compress/archivers/zip/ResourceAlignmentExtraField.java
index 79e20f6..3d0741c 100644
--- a/src/main/java/org/apache/commons/compress/archivers/zip/ResourceAlignmentExtraField.java
+++ b/src/main/java/org/apache/commons/compress/archivers/zip/ResourceAlignmentExtraField.java
@@ -64,8 +64,9 @@ public class ResourceAlignmentExtraField implements ZipExtraField {
     }
 
     public ResourceAlignmentExtraField(int alignment, boolean allowMethodChange, int padding) {
-        if (alignment < 0 || alignment > 0x7fff)
+        if (alignment < 0 || alignment > 0x7fff) {
             throw new IllegalArgumentException("Alignment must be between 0 and 0x7fff, was: " + alignment);
+        }
         this.alignment = (short) alignment;
         this.allowMethodChange = allowMethodChange;
         this.padding = padding;

http://git-wip-us.apache.org/repos/asf/commons-compress/blob/591b9f97/src/main/java/org/apache/commons/compress/archivers/zip/ZipArchiveOutputStream.java
----------------------------------------------------------------------
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 c667356..2b3af25 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
@@ -1057,7 +1057,7 @@ public class ZipArchiveOutputStream extends ArchiveOutputStream {
                             - ResourceAlignmentExtraField.BASE_SIZE) &
                             (alignment - 1));
             ze.addExtraField(new ResourceAlignmentExtraField(alignment,
-                            oldAlignmentEx != null ? oldAlignmentEx.allowMethodChange() : false, padding));
+                            oldAlignmentEx != null && oldAlignmentEx.allowMethodChange(), padding));
         }
 
         final byte[] extra = ze.getLocalFileDataExtra();

http://git-wip-us.apache.org/repos/asf/commons-compress/blob/591b9f97/src/main/java/org/apache/commons/compress/compressors/brotli/BrotliCompressorInputStream.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/commons/compress/compressors/brotli/BrotliCompressorInputStream.java b/src/main/java/org/apache/commons/compress/compressors/brotli/BrotliCompressorInputStream.java
index 135988d..91e57ca 100644
--- a/src/main/java/org/apache/commons/compress/compressors/brotli/BrotliCompressorInputStream.java
+++ b/src/main/java/org/apache/commons/compress/compressors/brotli/BrotliCompressorInputStream.java
@@ -17,7 +17,6 @@
 
 package org.apache.commons.compress.compressors.brotli;
 
-import java.io.FilterInputStream;
 import java.io.IOException;
 import java.io.InputStream;
 

http://git-wip-us.apache.org/repos/asf/commons-compress/blob/591b9f97/src/main/java/org/apache/commons/compress/compressors/lz4/BlockLZ4CompressorOutputStream.java
----------------------------------------------------------------------
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 9330ea8..9326023 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
@@ -40,7 +40,6 @@ import org.apache.commons.compress.utils.ByteUtils;
 public class BlockLZ4CompressorOutputStream extends CompressorOutputStream {
 
     private static final int MIN_BACK_REFERENCE_LENGTH = 4;
-    private static final int MIN_LENGTH_OF_LAST_LITERAL = 5;
     private static final int MIN_OFFSET_OF_LAST_BACK_REFERENCE = 12;
 
     /*

http://git-wip-us.apache.org/repos/asf/commons-compress/blob/591b9f97/src/main/java/org/apache/commons/compress/compressors/lz77support/Parameters.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/commons/compress/compressors/lz77support/Parameters.java b/src/main/java/org/apache/commons/compress/compressors/lz77support/Parameters.java
index d61ff65..fe892f3 100644
--- a/src/main/java/org/apache/commons/compress/compressors/lz77support/Parameters.java
+++ b/src/main/java/org/apache/commons/compress/compressors/lz77support/Parameters.java
@@ -248,7 +248,7 @@ public final class Parameters {
             int niceLen = niceBackReferenceLength != null ? niceBackReferenceLength
                 : Math.max(minBackReferenceLength, maxBackReferenceLength / 2);
             int candidates = maxCandidates != null ? maxCandidates : Math.max(256, windowSize / 128);
-            boolean lazy = lazyMatches != null ? lazyMatches : true;
+            boolean lazy = lazyMatches == null || lazyMatches;
             int threshold = lazy ? (lazyThreshold != null ? lazyThreshold : niceLen) : minBackReferenceLength;
 
             return new Parameters(windowSize, minBackReferenceLength, maxBackReferenceLength,


[3/3] commons-compress git commit: findbugs findings

Posted by bo...@apache.org.
findbugs findings


Project: http://git-wip-us.apache.org/repos/asf/commons-compress/repo
Commit: http://git-wip-us.apache.org/repos/asf/commons-compress/commit/0daa8708
Tree: http://git-wip-us.apache.org/repos/asf/commons-compress/tree/0daa8708
Diff: http://git-wip-us.apache.org/repos/asf/commons-compress/diff/0daa8708

Branch: refs/heads/master
Commit: 0daa8708dfcc5c0c3803ab2e41542dba134d71d0
Parents: 591b9f9
Author: Stefan Bodewig <bo...@apache.org>
Authored: Thu May 11 20:48:49 2017 +0200
Committer: Stefan Bodewig <bo...@apache.org>
Committed: Thu May 11 20:48:49 2017 +0200

----------------------------------------------------------------------
 .../apache/commons/compress/archivers/zip/ZipFile.java    |  2 +-
 .../compressors/brotli/BrotliCompressorInputStream.java   | 10 ----------
 2 files changed, 1 insertion(+), 11 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/commons-compress/blob/0daa8708/src/main/java/org/apache/commons/compress/archivers/zip/ZipFile.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/commons/compress/archivers/zip/ZipFile.java b/src/main/java/org/apache/commons/compress/archivers/zip/ZipFile.java
index 486d5e7..4b16b52 100644
--- a/src/main/java/org/apache/commons/compress/archivers/zip/ZipFile.java
+++ b/src/main/java/org/apache/commons/compress/archivers/zip/ZipFile.java
@@ -1162,7 +1162,7 @@ public class ZipFile implements Closeable {
             return read;
         }
 
-        void addDummy() {
+        synchronized void addDummy() {
             this.addDummy = true;
         }
     }

http://git-wip-us.apache.org/repos/asf/commons-compress/blob/0daa8708/src/main/java/org/apache/commons/compress/compressors/brotli/BrotliCompressorInputStream.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/commons/compress/compressors/brotli/BrotliCompressorInputStream.java b/src/main/java/org/apache/commons/compress/compressors/brotli/BrotliCompressorInputStream.java
index 91e57ca..6c4bc55 100644
--- a/src/main/java/org/apache/commons/compress/compressors/brotli/BrotliCompressorInputStream.java
+++ b/src/main/java/org/apache/commons/compress/compressors/brotli/BrotliCompressorInputStream.java
@@ -47,21 +47,11 @@ public class BrotliCompressorInputStream extends CompressorInputStream {
     }
 
     @Override
-    public int hashCode() {
-        return decIS.hashCode();
-    }
-
-    @Override
     public int read(final byte[] b) throws IOException {
         return decIS.read(b);
     }
 
     @Override
-    public boolean equals(final Object obj) {
-        return decIS.equals(obj);
-    }
-
-    @Override
     public long skip(final long n) throws IOException {
         return decIS.skip(n);
     }