commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bode...@apache.org
Subject [01/12] commons-compress git commit: Remove methods and change test + throw to assert to please the coveralls
Date Wed, 05 Jul 2017 15:34:20 GMT
Repository: commons-compress
Updated Branches:
  refs/heads/master 60a459abe -> 9ae52491c


Remove methods and change test + throw to assert to please the coveralls

Signed-off-by: Simon Spero <sesuncedu@gmail.com>


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

Branch: refs/heads/master
Commit: 90a73a4dee53129e33a552e49cb7835ecebb3a5f
Parents: d7e6e16
Author: Simon Spero <sesuncedu@gmail.com>
Authored: Mon Jun 19 06:07:02 2017 -0400
Committer: Stefan Bodewig <bodewig@apache.org>
Committed: Wed Jul 5 16:30:00 2017 +0200

----------------------------------------------------------------------
 .../compress/archivers/zip/NioZipEncoding.java  | 20 +++-------
 .../archivers/zip/ZipEncodingHelper.java        | 41 --------------------
 2 files changed, 6 insertions(+), 55 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/commons-compress/blob/90a73a4d/src/main/java/org/apache/commons/compress/archivers/zip/NioZipEncoding.java
----------------------------------------------------------------------
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 fed597f..606ab12 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
@@ -42,15 +42,10 @@ class NioZipEncoding implements ZipEncoding,HasCharset {
     private static final String REPLACEMENT_STRING = "?";
 
     /**
-     * Construct an NIO based zip encoding, which wraps the given
-     * charset.
-     *
-     * @param charset The NIO charset to wrap.
+     * Construct an NioZipEncoding using the given charset.
+     * @param charset  The character set to use.
+     * @param useReplacement should invalid characters be replaced, or reported.
      */
-    NioZipEncoding(final Charset charset) {
-        this(charset, false);
-    }
-
     NioZipEncoding(final Charset charset, boolean useReplacement) {
         this.charset = charset;
         this.useReplacement = useReplacement;
@@ -148,9 +143,8 @@ class NioZipEncoding implements ZipEncoding,HasCharset {
         }
         CoderResult coderResult = enc.encode(cb, out, true);
 
-        if (!coderResult.isUnderflow()) {
-            throw new RuntimeException("unexpected coder result: " + coderResult);
-        }
+        assert coderResult.isUnderflow() : "unexpected coder result: " + coderResult;
+        
 
         out.limit(out.position());
         out.rewind();
@@ -163,9 +157,7 @@ class NioZipEncoding implements ZipEncoding,HasCharset {
             if (result.isOverflow()) {
                 int increment = estimateIncrementalEncodingSize(enc, cb.remaining());
                 out = ZipEncodingHelper.growBufferBy(out, increment);
-            } else {
-                break;
-            }
+            } 
         }
         return out;
     }

http://git-wip-us.apache.org/repos/asf/commons-compress/blob/90a73a4d/src/main/java/org/apache/commons/compress/archivers/zip/ZipEncodingHelper.java
----------------------------------------------------------------------
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 f31d75c..fb550fd 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
@@ -28,29 +28,6 @@ import org.apache.commons.compress.utils.Charsets;
  */
 public abstract class ZipEncodingHelper {
 
-    /**
-     * Grow a byte buffer, so it has a minimal capacity or at least
-     * the double capacity of the original buffer
-     *
-     * @param b The original buffer.
-     * @param newCapacity The minimal requested new capacity.
-     * @return A byte buffer <code>r</code> with
-     *         <code>r.capacity() = max(b.capacity()*2,newCapacity)</code> and
-     *         all the data contained in <code>b</code> copied to the beginning
-     *         of <code>r</code>.
-     *
-     */
-    static ByteBuffer growBuffer(final ByteBuffer b, final int newCapacity) {
-        b.limit(b.position());
-        b.rewind();
-
-        final int c2 = b.capacity() * 2;
-        final ByteBuffer on = ByteBuffer.allocate(c2 < newCapacity ? newCapacity : c2);
-
-        on.put(b);
-        return on;
-    }
-
 
     /**
      * The hexadecimal digits <code>0,...,9,A,...,F</code> encoded as
@@ -62,24 +39,6 @@ public abstract class ZipEncodingHelper {
         0x42, 0x43, 0x44, 0x45, 0x46
     };
 
-    /**
-     * Append <code>%Uxxxx</code> to the given byte buffer.
-     * The caller must assure, that <code>bb.remaining()&gt;=6</code>.
-     *
-     * @param bb The byte buffer to write to.
-     * @param c The character to write.
-     */
-    static void appendSurrogate(final ByteBuffer bb, final char c) {
-
-        bb.put((byte) '%');
-        bb.put((byte) 'U');
-
-        bb.put(HEX_DIGITS[(c >> 12)&0x0f]);
-        bb.put(HEX_DIGITS[(c >> 8)&0x0f]);
-        bb.put(HEX_DIGITS[(c >> 4)&0x0f]);
-        bb.put(HEX_DIGITS[c & 0x0f]);
-    }
-
 
     /**
      * name of the encoding UTF-8


Mime
View raw message