Return-Path: X-Original-To: archive-asf-public-internal@cust-asf2.ponee.io Delivered-To: archive-asf-public-internal@cust-asf2.ponee.io Received: from cust-asf.ponee.io (cust-asf.ponee.io [163.172.22.183]) by cust-asf2.ponee.io (Postfix) with ESMTP id 8435C200CC2 for ; Wed, 5 Jul 2017 17:34:22 +0200 (CEST) Received: by cust-asf.ponee.io (Postfix) id 82A4F163A7C; Wed, 5 Jul 2017 15:34:22 +0000 (UTC) Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by cust-asf.ponee.io (Postfix) with SMTP id CAECA163A7B for ; Wed, 5 Jul 2017 17:34:21 +0200 (CEST) Received: (qmail 34644 invoked by uid 500); 5 Jul 2017 15:34:20 -0000 Mailing-List: contact commits-help@commons.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@commons.apache.org Delivered-To: mailing list commits@commons.apache.org Received: (qmail 34629 invoked by uid 99); 5 Jul 2017 15:34:20 -0000 Received: from git1-us-west.apache.org (HELO git1-us-west.apache.org) (140.211.11.23) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 05 Jul 2017 15:34:20 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id C8890E037F; Wed, 5 Jul 2017 15:34:20 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: bodewig@apache.org To: commits@commons.apache.org Date: Wed, 05 Jul 2017 15:34:20 -0000 Message-Id: X-Mailer: ASF-Git Admin Mailer Subject: [01/12] commons-compress git commit: Remove methods and change test + throw to assert to please the coveralls archived-at: Wed, 05 Jul 2017 15:34:22 -0000 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 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 Authored: Mon Jun 19 06:07:02 2017 -0400 Committer: Stefan Bodewig 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 r with - * r.capacity() = max(b.capacity()*2,newCapacity) and - * all the data contained in b copied to the beginning - * of r. - * - */ - 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 0,...,9,A,...,F encoded as @@ -62,24 +39,6 @@ public abstract class ZipEncodingHelper { 0x42, 0x43, 0x44, 0x45, 0x46 }; - /** - * Append %Uxxxx to the given byte buffer. - * The caller must assure, that bb.remaining()>=6. - * - * @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