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 D574C200CB1 for ; Sat, 24 Jun 2017 18:17:34 +0200 (CEST) Received: by cust-asf.ponee.io (Postfix) id D3A25160BE6; Sat, 24 Jun 2017 16:17:34 +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 F3B46160BDA for ; Sat, 24 Jun 2017 18:17:33 +0200 (CEST) Received: (qmail 89578 invoked by uid 500); 24 Jun 2017 16:17:32 -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 89569 invoked by uid 99); 24 Jun 2017 16:17:32 -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; Sat, 24 Jun 2017 16:17:32 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id 25C2FDFE22; Sat, 24 Jun 2017 16:17:30 +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 Message-Id: <4dc8b41cd9264ab48fbc070b68b71f35@git.apache.org> X-Mailer: ASF-Git Admin Mailer Subject: commons-compress git commit: make Sonar less unhappy Date: Sat, 24 Jun 2017 16:17:30 +0000 (UTC) archived-at: Sat, 24 Jun 2017 16:17:35 -0000 Repository: commons-compress Updated Branches: refs/heads/master fb9b61804 -> c93d3e1d7 make Sonar less unhappy Project: http://git-wip-us.apache.org/repos/asf/commons-compress/repo Commit: http://git-wip-us.apache.org/repos/asf/commons-compress/commit/c93d3e1d Tree: http://git-wip-us.apache.org/repos/asf/commons-compress/tree/c93d3e1d Diff: http://git-wip-us.apache.org/repos/asf/commons-compress/diff/c93d3e1d Branch: refs/heads/master Commit: c93d3e1d7db2971a4e1e7e79d7bf933268cb970e Parents: fb9b618 Author: Stefan Bodewig Authored: Sat Jun 24 18:10:45 2017 +0200 Committer: Stefan Bodewig Committed: Sat Jun 24 18:16:31 2017 +0200 ---------------------------------------------------------------------- .../archivers/zip/ZipArchiveOutputStream.java | 3 +- .../compress/archivers/zip/ZipConstants.java | 4 +-- .../utils/FixedLengthBlockOutputStream.java | 33 +++++++++++--------- 3 files changed, 23 insertions(+), 17 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/commons-compress/blob/c93d3e1d/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 63aeba7..cb594f2 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 @@ -760,7 +760,8 @@ public class ZipArchiveOutputStream extends ArchiveOutputStream { final Zip64ExtendedInformationExtraField z64 = getZip64Extra(entry.entry); - ZipEightByteInteger size, compressedSize; + ZipEightByteInteger size; + ZipEightByteInteger compressedSize; if (phased) { // sizes are already known size = new ZipEightByteInteger(entry.entry.getSize()); http://git-wip-us.apache.org/repos/asf/commons-compress/blob/c93d3e1d/src/main/java/org/apache/commons/compress/archivers/zip/ZipConstants.java ---------------------------------------------------------------------- diff --git a/src/main/java/org/apache/commons/compress/archivers/zip/ZipConstants.java b/src/main/java/org/apache/commons/compress/archivers/zip/ZipConstants.java index 23f04a8..c230991 100644 --- a/src/main/java/org/apache/commons/compress/archivers/zip/ZipConstants.java +++ b/src/main/java/org/apache/commons/compress/archivers/zip/ZipConstants.java @@ -23,8 +23,6 @@ package org.apache.commons.compress.archivers.zip; * @since 1.3 */ final class ZipConstants { - private ZipConstants() { } - /** Masks last eight bits */ static final int BYTE_MASK = 0xFF; @@ -64,4 +62,6 @@ final class ZipConstants { */ static final long ZIP64_MAGIC = 0xFFFFFFFFL; + private ZipConstants() { } + } http://git-wip-us.apache.org/repos/asf/commons-compress/blob/c93d3e1d/src/main/java/org/apache/commons/compress/utils/FixedLengthBlockOutputStream.java ---------------------------------------------------------------------- diff --git a/src/main/java/org/apache/commons/compress/utils/FixedLengthBlockOutputStream.java b/src/main/java/org/apache/commons/compress/utils/FixedLengthBlockOutputStream.java index 8fe6d20..6c93f34 100644 --- a/src/main/java/org/apache/commons/compress/utils/FixedLengthBlockOutputStream.java +++ b/src/main/java/org/apache/commons/compress/utils/FixedLengthBlockOutputStream.java @@ -102,7 +102,7 @@ public class FixedLengthBlockOutputStream extends OutputStream implements Writab @Override public void write(int b) throws IOException { - if(!isOpen()) { + if (!isOpen()) { throw new ClosedChannelException(); } buffer.put((byte) b); @@ -110,10 +110,12 @@ public class FixedLengthBlockOutputStream extends OutputStream implements Writab } @Override - public void write(byte[] b, int off, int len) throws IOException { - if(!isOpen()) { + public void write(byte[] b, final int offset, final int length) throws IOException { + if (!isOpen()) { throw new ClosedChannelException(); } + int off = offset; + int len = length; while (len > 0) { int n = Math.min(len, buffer.remaining()); buffer.put(b, off, n); @@ -125,7 +127,7 @@ public class FixedLengthBlockOutputStream extends OutputStream implements Writab @Override public int write(ByteBuffer src) throws IOException { - if(!isOpen()) { + if (!isOpen()) { throw new ClosedChannelException(); } int srcRemaining = src.remaining(); @@ -161,7 +163,7 @@ public class FixedLengthBlockOutputStream extends OutputStream implements Writab @Override public boolean isOpen() { - if(!out.isOpen()) { + if (!out.isOpen()) { closed.set(true); } return !closed.get(); @@ -182,7 +184,7 @@ public class FixedLengthBlockOutputStream extends OutputStream implements Writab buffer.order(ByteOrder.nativeOrder()); int bytesToWrite = buffer.remaining(); if (bytesToWrite > 8) { - int align = (buffer.position() & 7); + int align = buffer.position() & 7; if (align != 0) { int limit = 8 - align; for (int i = 0; i < limit; i++) { @@ -218,9 +220,12 @@ public class FixedLengthBlockOutputStream extends OutputStream implements Writab @Override public int write(ByteBuffer buffer) throws IOException { - assert isOpen() : "somehow trying to write to closed BufferAtATimeOutputChannel"; - assert buffer.hasArray() : - "direct buffer somehow written to BufferAtATimeOutputChannel"; + if (!isOpen()) { + throw new ClosedChannelException(); + } + if (!buffer.hasArray()) { + throw new IllegalArgumentException("direct buffer somehow written to BufferAtATimeOutputChannel"); + } try { int pos = buffer.position(); @@ -229,11 +234,11 @@ public class FixedLengthBlockOutputStream extends OutputStream implements Writab buffer.position(buffer.limit()); return len; } catch (IOException e) { - try { - close(); - } finally { - throw e; - } + try { + close(); + } catch (IOException ignored) { //NOSONAR + } + throw e; } }