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 2019/08/23 15:13:14 UTC

[commons-compress] branch master updated (16a0c84 -> 34c3311)

This is an automated email from the ASF dual-hosted git repository.

bodewig pushed a change to branch master
in repository https://gitbox.apache.org/repos/asf/commons-compress.git.


    from 16a0c84  the default options should be final
     new 4ad5d80  unit tests for encoding logic
     new b2f97b2  avoid NPE warning in Sonar
     new 34590ca  Sonar now does HTML linting
     new 931b42b  typo
     new 34c3311  hasRemaining may be faster that actually counting elements

The 5 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:
 .../commons/compress/archivers/ar/package.html     |  6 +-
 .../commons/compress/archivers/arj/package.html    |  6 +-
 .../commons/compress/archivers/cpio/package.html   |  6 +-
 .../commons/compress/archivers/dump/package.html   |  6 +-
 .../compress/archivers/examples/package.html       |  6 +-
 .../commons/compress/archivers/jar/package.html    |  6 +-
 .../apache/commons/compress/archivers/package.html |  6 +-
 .../commons/compress/archivers/sevenz/package.html |  6 +-
 .../commons/compress/archivers/tar/package.html    |  6 +-
 .../compress/archivers/zip/NioZipEncoding.java     |  5 +-
 .../archivers/zip/ZipArchiveInputStream.java       |  4 +-
 .../commons/compress/archivers/zip/package.html    |  6 +-
 .../apache/commons/compress/changes/package.html   |  6 +-
 .../compress/compressors/brotli/package.html       |  6 +-
 .../compress/compressors/bzip2/package.html        |  6 +-
 .../compress/compressors/deflate/package.html      |  6 +-
 .../compress/compressors/deflate64/package.html    |  6 +-
 .../commons/compress/compressors/gzip/package.html |  6 +-
 .../commons/compress/compressors/lz4/package.html  |  6 +-
 .../compress/compressors/lz77support/package.html  |  6 +-
 .../commons/compress/compressors/lzma/package.html |  6 +-
 .../commons/compress/compressors/lzw/package.html  |  6 +-
 .../compress/compressors/pack200/package.html      |  6 +-
 .../commons/compress/compressors/package.html      |  6 +-
 .../compress/compressors/snappy/package.html       |  6 +-
 .../commons/compress/compressors/xz/package.html   |  6 +-
 .../commons/compress/compressors/z/package.html    |  6 +-
 .../compress/compressors/zstandard/package.html    |  6 +-
 .../apache/commons/compress/parallel/package.html  |  6 +-
 .../org/apache/commons/compress/utils/package.html |  6 +-
 src/site/xdoc/examples.xml                         |  2 +-
 .../compress/archivers/zip/NioZipEncodingTest.java | 97 ++++++++++++++++++++++
 32 files changed, 244 insertions(+), 32 deletions(-)
 create mode 100644 src/test/java/org/apache/commons/compress/archivers/zip/NioZipEncodingTest.java


[commons-compress] 04/05: typo

Posted by bo...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

bodewig pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/commons-compress.git

commit 931b42b4b9e29eedf0adce3909655cb47522ce9b
Author: Stefan Bodewig <bo...@apache.org>
AuthorDate: Fri Aug 23 17:10:09 2019 +0200

    typo
---
 src/site/xdoc/examples.xml | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/site/xdoc/examples.xml b/src/site/xdoc/examples.xml
index b295e77..488bbb5 100644
--- a/src/site/xdoc/examples.xml
+++ b/src/site/xdoc/examples.xml
@@ -163,7 +163,7 @@ CompressorInputStream input = new CompressorStreamFactory()
         <p>Assuming you want to extract an archive to a target
         directory you'd call <code>getNextEntry</code>, verify the
         entry can be read, construct a sane file name from the entry's
-        name, create a <codee>File</codee> and write all contents to
+        name, create a <code>File</code> and write all contents to
         it - here <code>IOUtils.copy</code> may come handy. You do so
         for every entry until <code>getNextEntry</code> returns
         <code>null</code>.</p>


[commons-compress] 05/05: hasRemaining may be faster that actually counting elements

Posted by bo...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

bodewig pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/commons-compress.git

commit 34c3311d406c648a7b6ada342bf4c294fd81a6ee
Author: Stefan Bodewig <bo...@apache.org>
AuthorDate: Fri Aug 23 17:12:01 2019 +0200

    hasRemaining may be faster that actually counting elements
---
 .../java/org/apache/commons/compress/archivers/zip/NioZipEncoding.java  | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

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 4ce9c20..401f9fa 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
@@ -82,7 +82,7 @@ class NioZipEncoding implements ZipEncoding, CharsetAccessor {
         CharBuffer tmp = null;
         ByteBuffer out = ByteBuffer.allocate(estimateInitialBufferSize(enc, cb.remaining()));
 
-        while (cb.remaining() > 0) {
+        while (cb.hasRemaining()) {
             final CoderResult res = enc.encode(cb, out, false);
 
             if (res.isUnmappable() || res.isMalformed()) {


[commons-compress] 03/05: Sonar now does HTML linting

Posted by bo...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

bodewig pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/commons-compress.git

commit 34590ca9ccda7b63e5f57906f1b9b12bf6efd56c
Author: Stefan Bodewig <bo...@apache.org>
AuthorDate: Fri Aug 23 17:08:05 2019 +0200

    Sonar now does HTML linting
    
    even for package.html where the HTML head gets ignored anyway
---
 src/main/java/org/apache/commons/compress/archivers/ar/package.html | 6 +++++-
 .../java/org/apache/commons/compress/archivers/arj/package.html     | 6 +++++-
 .../java/org/apache/commons/compress/archivers/cpio/package.html    | 6 +++++-
 .../java/org/apache/commons/compress/archivers/dump/package.html    | 6 +++++-
 .../org/apache/commons/compress/archivers/examples/package.html     | 6 +++++-
 .../java/org/apache/commons/compress/archivers/jar/package.html     | 6 +++++-
 src/main/java/org/apache/commons/compress/archivers/package.html    | 6 +++++-
 .../java/org/apache/commons/compress/archivers/sevenz/package.html  | 6 +++++-
 .../java/org/apache/commons/compress/archivers/tar/package.html     | 6 +++++-
 .../java/org/apache/commons/compress/archivers/zip/package.html     | 6 +++++-
 src/main/java/org/apache/commons/compress/changes/package.html      | 6 +++++-
 .../org/apache/commons/compress/compressors/brotli/package.html     | 6 +++++-
 .../java/org/apache/commons/compress/compressors/bzip2/package.html | 6 +++++-
 .../org/apache/commons/compress/compressors/deflate/package.html    | 6 +++++-
 .../org/apache/commons/compress/compressors/deflate64/package.html  | 6 +++++-
 .../java/org/apache/commons/compress/compressors/gzip/package.html  | 6 +++++-
 .../java/org/apache/commons/compress/compressors/lz4/package.html   | 6 +++++-
 .../apache/commons/compress/compressors/lz77support/package.html    | 6 +++++-
 .../java/org/apache/commons/compress/compressors/lzma/package.html  | 6 +++++-
 .../java/org/apache/commons/compress/compressors/lzw/package.html   | 6 +++++-
 .../org/apache/commons/compress/compressors/pack200/package.html    | 6 +++++-
 src/main/java/org/apache/commons/compress/compressors/package.html  | 6 +++++-
 .../org/apache/commons/compress/compressors/snappy/package.html     | 6 +++++-
 .../java/org/apache/commons/compress/compressors/xz/package.html    | 6 +++++-
 .../java/org/apache/commons/compress/compressors/z/package.html     | 6 +++++-
 .../org/apache/commons/compress/compressors/zstandard/package.html  | 6 +++++-
 src/main/java/org/apache/commons/compress/parallel/package.html     | 6 +++++-
 src/main/java/org/apache/commons/compress/utils/package.html        | 6 +++++-
 28 files changed, 140 insertions(+), 28 deletions(-)

diff --git a/src/main/java/org/apache/commons/compress/archivers/ar/package.html b/src/main/java/org/apache/commons/compress/archivers/ar/package.html
index 9c80f96..4cee6b6 100644
--- a/src/main/java/org/apache/commons/compress/archivers/ar/package.html
+++ b/src/main/java/org/apache/commons/compress/archivers/ar/package.html
@@ -1,4 +1,5 @@
-<html>
+<!DOCTYPE html>
+<html lang="en">
 <!--
 
    Licensed to the Apache Software Foundation (ASF) under one or more
@@ -17,6 +18,9 @@
    limitations under the License.
 
 -->
+  <head>
+    <title>ar package</title>
+  </head>
   <body>
     <p>Provides stream classes for reading and writing archives using
       the AR format.</p>
diff --git a/src/main/java/org/apache/commons/compress/archivers/arj/package.html b/src/main/java/org/apache/commons/compress/archivers/arj/package.html
index de18f61..3e3abd2 100644
--- a/src/main/java/org/apache/commons/compress/archivers/arj/package.html
+++ b/src/main/java/org/apache/commons/compress/archivers/arj/package.html
@@ -1,4 +1,5 @@
-<html>
+<!DOCTYPE html>
+<html lang="en">
 <!--
 
    Licensed to the Apache Software Foundation (ASF) under one or more
@@ -17,6 +18,9 @@
    limitations under the License.
 
 -->
+  <head>
+    <title>arj package</title>
+  </head>
   <body>
     <p>Provides stream classes for reading archives using
       the ARJ format.</p>
diff --git a/src/main/java/org/apache/commons/compress/archivers/cpio/package.html b/src/main/java/org/apache/commons/compress/archivers/cpio/package.html
index 9858287..e52904e 100644
--- a/src/main/java/org/apache/commons/compress/archivers/cpio/package.html
+++ b/src/main/java/org/apache/commons/compress/archivers/cpio/package.html
@@ -1,4 +1,5 @@
-<html>
+<!DOCTYPE html>
+<html lang="en">
 <!--
 
    Licensed to the Apache Software Foundation (ASF) under one or more
@@ -17,6 +18,9 @@
    limitations under the License.
 
 -->
+  <head>
+    <title>cpio package</title>
+  </head>
   <body>
     <p>Provides stream classes for reading and writing archives using
       the CPIO format.</p>
diff --git a/src/main/java/org/apache/commons/compress/archivers/dump/package.html b/src/main/java/org/apache/commons/compress/archivers/dump/package.html
index 72f3c68..e1fed41 100644
--- a/src/main/java/org/apache/commons/compress/archivers/dump/package.html
+++ b/src/main/java/org/apache/commons/compress/archivers/dump/package.html
@@ -1,4 +1,5 @@
-<html>
+<!DOCTYPE html>
+<html lang="en">
 <!--
 
    Licensed to the Apache Software Foundation (ASF) under one or more
@@ -17,6 +18,9 @@
    limitations under the License.
 
 -->
+  <head>
+    <title>dump package</title>
+  </head>
   <body>
     <p>This package provides stream classes for reading archives
       using the Unix DUMP format. This format is similar to (and 
diff --git a/src/main/java/org/apache/commons/compress/archivers/examples/package.html b/src/main/java/org/apache/commons/compress/archivers/examples/package.html
index 443d5fc..0858960 100644
--- a/src/main/java/org/apache/commons/compress/archivers/examples/package.html
+++ b/src/main/java/org/apache/commons/compress/archivers/examples/package.html
@@ -1,4 +1,5 @@
-<html>
+<!DOCTYPE html>
+<html lang="en">
 <!--
 
    Licensed to the Apache Software Foundation (ASF) under one or more
@@ -17,6 +18,9 @@
    limitations under the License.
 
 -->
+  <head>
+    <title>examples package</title>
+  </head>
   <body>
     <p>Contains example code that is not guaranteed to provide a
       stable API across releases of Commons Compress.</p>
diff --git a/src/main/java/org/apache/commons/compress/archivers/jar/package.html b/src/main/java/org/apache/commons/compress/archivers/jar/package.html
index 09829ae..ab06f02 100644
--- a/src/main/java/org/apache/commons/compress/archivers/jar/package.html
+++ b/src/main/java/org/apache/commons/compress/archivers/jar/package.html
@@ -1,4 +1,5 @@
-<html>
+<!DOCTYPE html>
+<html lang="en">
 <!--
 
    Licensed to the Apache Software Foundation (ASF) under one or more
@@ -17,6 +18,9 @@
    limitations under the License.
 
 -->
+  <head>
+    <title>jar package</title>
+  </head>
   <body>
     <p>Provides stream classes for reading and writing archives using
       the ZIP format with some extensions for the special case of JAR
diff --git a/src/main/java/org/apache/commons/compress/archivers/package.html b/src/main/java/org/apache/commons/compress/archivers/package.html
index df1922b..065592b 100644
--- a/src/main/java/org/apache/commons/compress/archivers/package.html
+++ b/src/main/java/org/apache/commons/compress/archivers/package.html
@@ -1,4 +1,5 @@
-<html>
+<!DOCTYPE html>
+<html lang="en">
 <!--
 
    Licensed to the Apache Software Foundation (ASF) under one or more
@@ -17,6 +18,9 @@
    limitations under the License.
 
 -->
+  <head>
+    <title>archivers package</title>
+  </head>
   <body>
     <p>Provides a unified API and factories for dealing with archives
       in different formats.</p>
diff --git a/src/main/java/org/apache/commons/compress/archivers/sevenz/package.html b/src/main/java/org/apache/commons/compress/archivers/sevenz/package.html
index 975703b..c5756f2 100644
--- a/src/main/java/org/apache/commons/compress/archivers/sevenz/package.html
+++ b/src/main/java/org/apache/commons/compress/archivers/sevenz/package.html
@@ -1,4 +1,5 @@
-<html>
+<!DOCTYPE html>
+<html lang="en">
 <!--
 
    Licensed to the Apache Software Foundation (ASF) under one or more
@@ -17,6 +18,9 @@
    limitations under the License.
 
 -->
+  <head>
+    <title>7z package</title>
+  </head>
   <body>
     <p>Provides classes for reading and writing archives using
       the 7z format.</p>
diff --git a/src/main/java/org/apache/commons/compress/archivers/tar/package.html b/src/main/java/org/apache/commons/compress/archivers/tar/package.html
index 141f33b..32f2dfd 100644
--- a/src/main/java/org/apache/commons/compress/archivers/tar/package.html
+++ b/src/main/java/org/apache/commons/compress/archivers/tar/package.html
@@ -1,4 +1,5 @@
-<html>
+<!DOCTYPE html>
+<html lang="en">
 <!--
 
    Licensed to the Apache Software Foundation (ASF) under one or more
@@ -17,6 +18,9 @@
    limitations under the License.
 
 -->
+  <head>
+    <title>tar package</title>
+  </head>
   <body>
     <p>Provides stream classes for reading and writing archives using
       the TAR format.</p>
diff --git a/src/main/java/org/apache/commons/compress/archivers/zip/package.html b/src/main/java/org/apache/commons/compress/archivers/zip/package.html
index 521687b..e8bd18f 100644
--- a/src/main/java/org/apache/commons/compress/archivers/zip/package.html
+++ b/src/main/java/org/apache/commons/compress/archivers/zip/package.html
@@ -1,4 +1,5 @@
-<html>
+<!DOCTYPE html>
+<html lang="en">
 <!--
 
    Licensed to the Apache Software Foundation (ASF) under one or more
@@ -17,6 +18,9 @@
    limitations under the License.
 
 -->
+  <head>
+    <title>zip package</title>
+  </head>
   <body>
     <p>Provides stream classes for reading and writing archives using
       the ZIP format.</p>
diff --git a/src/main/java/org/apache/commons/compress/changes/package.html b/src/main/java/org/apache/commons/compress/changes/package.html
index 4ba3e87..548f990 100644
--- a/src/main/java/org/apache/commons/compress/changes/package.html
+++ b/src/main/java/org/apache/commons/compress/changes/package.html
@@ -1,4 +1,5 @@
-<html>
+<!DOCTYPE html>
+<html lang="en">
 <!--
 
    Licensed to the Apache Software Foundation (ASF) under one or more
@@ -17,6 +18,9 @@
    limitations under the License.
 
 -->
+  <head>
+    <title>Changeset package</title>
+  </head>
   <body>
     <p><b>EXPERIMENTAL</b> support for changesets that are applied to
       archives.</p>
diff --git a/src/main/java/org/apache/commons/compress/compressors/brotli/package.html b/src/main/java/org/apache/commons/compress/compressors/brotli/package.html
index 7654cf6..45a1c39 100644
--- a/src/main/java/org/apache/commons/compress/compressors/brotli/package.html
+++ b/src/main/java/org/apache/commons/compress/compressors/brotli/package.html
@@ -1,4 +1,5 @@
-<html>
+<!DOCTYPE html>
+<html lang="en">
 <!--
 
    Licensed to the Apache Software Foundation (ASF) under one or more
@@ -17,6 +18,9 @@
    limitations under the License.
 
 -->
+  <head>
+    <title>brotli package</title>
+  </head>
   <body>
     <p>Provides stream class for decompressing streams using the
       Brotli algorithm based
diff --git a/src/main/java/org/apache/commons/compress/compressors/bzip2/package.html b/src/main/java/org/apache/commons/compress/compressors/bzip2/package.html
index fe27e6e..c3f189e 100644
--- a/src/main/java/org/apache/commons/compress/compressors/bzip2/package.html
+++ b/src/main/java/org/apache/commons/compress/compressors/bzip2/package.html
@@ -1,4 +1,5 @@
-<html>
+<!DOCTYPE html>
+<html lang="en">
 <!--
 
    Licensed to the Apache Software Foundation (ASF) under one or more
@@ -17,6 +18,9 @@
    limitations under the License.
 
 -->
+  <head>
+    <title>bzip2 package</title>
+  </head>
   <body>
     <p>Provides stream classes for compressing and decompressing
       streams using the BZip2 algorithm.</p>
diff --git a/src/main/java/org/apache/commons/compress/compressors/deflate/package.html b/src/main/java/org/apache/commons/compress/compressors/deflate/package.html
index 4ddeb74..c79fb68 100644
--- a/src/main/java/org/apache/commons/compress/compressors/deflate/package.html
+++ b/src/main/java/org/apache/commons/compress/compressors/deflate/package.html
@@ -1,4 +1,5 @@
-<html>
+<!DOCTYPE html>
+<html lang="en">
 <!--
 
    Licensed to the Apache Software Foundation (ASF) under one or more
@@ -17,6 +18,9 @@
    limitations under the License.
 
 -->
+  <head>
+    <title>deflate package</title>
+  </head>
   <body>
     <p>Provides a stream classes that allow (de)compressing streams
       using the DEFLATE algorithm.</p>
diff --git a/src/main/java/org/apache/commons/compress/compressors/deflate64/package.html b/src/main/java/org/apache/commons/compress/compressors/deflate64/package.html
index 4a0cdd0..2cf8a73 100644
--- a/src/main/java/org/apache/commons/compress/compressors/deflate64/package.html
+++ b/src/main/java/org/apache/commons/compress/compressors/deflate64/package.html
@@ -1,4 +1,5 @@
-<html>
+<!DOCTYPE html>
+<html lang="en">
 <!--
 
    Licensed to the Apache Software Foundation (ASF) under one or more
@@ -17,6 +18,9 @@
    limitations under the License.
 
 -->
+  <head>
+    <title>deflate64 package</title>
+  </head>
   <body>
     <p>Provides a stream that allows decompressing streams using the
       DEFLATE64(tm) algorithm. DEFLATE64 is a trademark of PKWARE,
diff --git a/src/main/java/org/apache/commons/compress/compressors/gzip/package.html b/src/main/java/org/apache/commons/compress/compressors/gzip/package.html
index e18b50f..05ffc33 100644
--- a/src/main/java/org/apache/commons/compress/compressors/gzip/package.html
+++ b/src/main/java/org/apache/commons/compress/compressors/gzip/package.html
@@ -1,4 +1,5 @@
-<html>
+<!DOCTYPE html>
+<html lang="en">
 <!--
 
    Licensed to the Apache Software Foundation (ASF) under one or more
@@ -17,6 +18,9 @@
    limitations under the License.
 
 -->
+  <head>
+    <title>gzip package</title>
+  </head>
   <body>
     <p>Provides stream classes for compressing and decompressing
       streams using the GZip algorithm.</p>
diff --git a/src/main/java/org/apache/commons/compress/compressors/lz4/package.html b/src/main/java/org/apache/commons/compress/compressors/lz4/package.html
index 54de62b..0c8d7b7 100644
--- a/src/main/java/org/apache/commons/compress/compressors/lz4/package.html
+++ b/src/main/java/org/apache/commons/compress/compressors/lz4/package.html
@@ -1,4 +1,5 @@
-<html>
+<!DOCTYPE html>
+<html lang="en">
 <!--
 
    Licensed to the Apache Software Foundation (ASF) under one or more
@@ -17,6 +18,9 @@
    limitations under the License.
 
 -->
+  <head>
+    <title>lz4 package</title>
+  </head>
   <body>
     <p>Provides stream classes for the
       <a href="http://lz4.github.io/lz4/">LZ4</a>
diff --git a/src/main/java/org/apache/commons/compress/compressors/lz77support/package.html b/src/main/java/org/apache/commons/compress/compressors/lz77support/package.html
index 951b146..11ba335 100644
--- a/src/main/java/org/apache/commons/compress/compressors/lz77support/package.html
+++ b/src/main/java/org/apache/commons/compress/compressors/lz77support/package.html
@@ -1,4 +1,5 @@
-<html>
+<!DOCTYPE html>
+<html lang="en">
 <!--
 
    Licensed to the Apache Software Foundation (ASF) under one or more
@@ -17,6 +18,9 @@
    limitations under the License.
 
 -->
+  <head>
+    <title>LZ77 support package</title>
+  </head>
   <body>
     <p>Provides utility classes for LZ77 based algorithms.</p>
 
diff --git a/src/main/java/org/apache/commons/compress/compressors/lzma/package.html b/src/main/java/org/apache/commons/compress/compressors/lzma/package.html
index f3b5473..c03a849 100644
--- a/src/main/java/org/apache/commons/compress/compressors/lzma/package.html
+++ b/src/main/java/org/apache/commons/compress/compressors/lzma/package.html
@@ -1,4 +1,5 @@
-<html>
+<!DOCTYPE html>
+<html lang="en">
 <!--
 
    Licensed to the Apache Software Foundation (ASF) under one or more
@@ -17,6 +18,9 @@
    limitations under the License.
 
 -->
+  <head>
+    <title>lzma package</title>
+  </head>
   <body>
     <p>Provides stream classes using the "stand-alone" LZMA
       algorithm.</p>
diff --git a/src/main/java/org/apache/commons/compress/compressors/lzw/package.html b/src/main/java/org/apache/commons/compress/compressors/lzw/package.html
index 3c45ca6..c0fe7cf 100644
--- a/src/main/java/org/apache/commons/compress/compressors/lzw/package.html
+++ b/src/main/java/org/apache/commons/compress/compressors/lzw/package.html
@@ -1,4 +1,5 @@
-<html>
+<!DOCTYPE html>
+<html lang="en">
 <!--
 
    Licensed to the Apache Software Foundation (ASF) under one or more
@@ -17,6 +18,9 @@
    limitations under the License.
 
 -->
+  <head>
+    <title>lzw package</title>
+  </head>
   <body>
     <p>Generic LZW implementation.</p>
   </body>
diff --git a/src/main/java/org/apache/commons/compress/compressors/pack200/package.html b/src/main/java/org/apache/commons/compress/compressors/pack200/package.html
index 9dbf2a0..8c1cc81 100644
--- a/src/main/java/org/apache/commons/compress/compressors/pack200/package.html
+++ b/src/main/java/org/apache/commons/compress/compressors/pack200/package.html
@@ -1,4 +1,5 @@
-<html>
+<!DOCTYPE html>
+<html lang="en">
 <!--
 
    Licensed to the Apache Software Foundation (ASF) under one or more
@@ -17,6 +18,9 @@
    limitations under the License.
 
 -->
+  <head>
+    <title>pack200 package</title>
+  </head>
   <body>
     <p>Provides stream classes for compressing and decompressing
       streams using the Pack200 algorithm used to compress Java
diff --git a/src/main/java/org/apache/commons/compress/compressors/package.html b/src/main/java/org/apache/commons/compress/compressors/package.html
index 7b7d504..d67758d 100644
--- a/src/main/java/org/apache/commons/compress/compressors/package.html
+++ b/src/main/java/org/apache/commons/compress/compressors/package.html
@@ -1,4 +1,5 @@
-<html>
+<!DOCTYPE html>
+<html lang="en">
 <!--
 
    Licensed to the Apache Software Foundation (ASF) under one or more
@@ -17,6 +18,9 @@
    limitations under the License.
 
 -->
+  <head>
+    <title>compressors package</title>
+  </head>
   <body>
     <p>Provides a unified API and factories for dealing with
       compressed streams.</p>
diff --git a/src/main/java/org/apache/commons/compress/compressors/snappy/package.html b/src/main/java/org/apache/commons/compress/compressors/snappy/package.html
index efef071..74e5178 100644
--- a/src/main/java/org/apache/commons/compress/compressors/snappy/package.html
+++ b/src/main/java/org/apache/commons/compress/compressors/snappy/package.html
@@ -1,4 +1,5 @@
-<html>
+<!DOCTYPE html>
+<html lang="en">
 <!--
 
    Licensed to the Apache Software Foundation (ASF) under one or more
@@ -17,6 +18,9 @@
    limitations under the License.
 
 -->
+  <head>
+    <title>snappy package</title>
+  </head>
   <body>
     <p>Provides stream classes for the
       <a href="https://github.com/google/snappy">Snappy</a>
diff --git a/src/main/java/org/apache/commons/compress/compressors/xz/package.html b/src/main/java/org/apache/commons/compress/compressors/xz/package.html
index 48eca25..e138e50 100644
--- a/src/main/java/org/apache/commons/compress/compressors/xz/package.html
+++ b/src/main/java/org/apache/commons/compress/compressors/xz/package.html
@@ -1,4 +1,5 @@
-<html>
+<!DOCTYPE html>
+<html lang="en">
 <!--
 
    Licensed to the Apache Software Foundation (ASF) under one or more
@@ -17,6 +18,9 @@
    limitations under the License.
 
 -->
+  <head>
+    <title>xz package</title>
+  </head>
   <body>
     <p>Provides stream classes for compressing and decompressing
       streams using the XZ algorithm.</p>
diff --git a/src/main/java/org/apache/commons/compress/compressors/z/package.html b/src/main/java/org/apache/commons/compress/compressors/z/package.html
index ca9924b..e04f319 100644
--- a/src/main/java/org/apache/commons/compress/compressors/z/package.html
+++ b/src/main/java/org/apache/commons/compress/compressors/z/package.html
@@ -1,4 +1,5 @@
-<html>
+<!DOCTYPE html>
+<html lang="en">
 <!--
 
    Licensed to the Apache Software Foundation (ASF) under one or more
@@ -17,6 +18,9 @@
    limitations under the License.
 
 -->
+  <head>
+    <title>compress package</title>
+  </head>
   <body>
     <p>Provides stream classes for decompressing
       streams using the "compress" algorithm used to write .Z files.</p>
diff --git a/src/main/java/org/apache/commons/compress/compressors/zstandard/package.html b/src/main/java/org/apache/commons/compress/compressors/zstandard/package.html
index 6deb74f..f432991 100644
--- a/src/main/java/org/apache/commons/compress/compressors/zstandard/package.html
+++ b/src/main/java/org/apache/commons/compress/compressors/zstandard/package.html
@@ -1,4 +1,5 @@
-<html>
+<!DOCTYPE html>
+<html lang="en">
 <!--
 
    Licensed to the Apache Software Foundation (ASF) under one or more
@@ -17,6 +18,9 @@
    limitations under the License.
 
 -->
+  <head>
+    <title>Zstandard package</title>
+  </head>
   <body>
     <p>Provides stream class for (de)compressing streams using the
       Zstandard algorithm based
diff --git a/src/main/java/org/apache/commons/compress/parallel/package.html b/src/main/java/org/apache/commons/compress/parallel/package.html
index 3517bc5..9977aa3 100644
--- a/src/main/java/org/apache/commons/compress/parallel/package.html
+++ b/src/main/java/org/apache/commons/compress/parallel/package.html
@@ -1,4 +1,5 @@
-<html>
+<!DOCTYPE html>
+<html lang="en">
 <!--
 
    Licensed to the Apache Software Foundation (ASF) under one or more
@@ -17,6 +18,9 @@
    limitations under the License.
 
 -->
+  <head>
+    <title>parallel package</title>
+  </head>
   <body>
     <p>Provides common API classes for parallel compression features.</p>
   </body>
diff --git a/src/main/java/org/apache/commons/compress/utils/package.html b/src/main/java/org/apache/commons/compress/utils/package.html
index 0409d12..985999d 100644
--- a/src/main/java/org/apache/commons/compress/utils/package.html
+++ b/src/main/java/org/apache/commons/compress/utils/package.html
@@ -1,4 +1,5 @@
-<html>
+<!DOCTYPE html>
+<html lang="en">
 <!--
 
    Licensed to the Apache Software Foundation (ASF) under one or more
@@ -17,6 +18,9 @@
    limitations under the License.
 
 -->
+  <head>
+    <title>Utility package</title>
+  </head>
   <body>
     <p>Contains utilities used internally by the compress library.</p>
   </body>


[commons-compress] 01/05: unit tests for encoding logic

Posted by bo...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

bodewig pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/commons-compress.git

commit 4ad5d80a6272e007f64a6ac66829ca189a8093b9
Author: Stefan Bodewig <bo...@apache.org>
AuthorDate: Fri Aug 23 16:12:05 2019 +0200

    unit tests for encoding logic
---
 .../compress/archivers/zip/NioZipEncoding.java     |  3 +
 .../compress/archivers/zip/NioZipEncodingTest.java | 97 ++++++++++++++++++++++
 2 files changed, 100 insertions(+)

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 0a7581a..4ce9c20 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
@@ -112,6 +112,9 @@ class NioZipEncoding implements ZipEncoding, CharsetAccessor {
             } else if (res.isOverflow()) {
                 int increment = estimateIncrementalEncodingSize(enc, cb.remaining());
                 out = ZipEncodingHelper.growBufferBy(out, increment);
+
+            } else if (res.isUnderflow() || res.isError()) {
+                break;
             }
         }
         // tell the encoder we are done
diff --git a/src/test/java/org/apache/commons/compress/archivers/zip/NioZipEncodingTest.java b/src/test/java/org/apache/commons/compress/archivers/zip/NioZipEncodingTest.java
new file mode 100644
index 0000000..a04730c
--- /dev/null
+++ b/src/test/java/org/apache/commons/compress/archivers/zip/NioZipEncodingTest.java
@@ -0,0 +1,97 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.commons.compress.archivers.zip;
+
+import java.nio.ByteBuffer;
+import java.nio.charset.StandardCharsets;
+import java.util.Arrays;
+
+import org.junit.Assert;
+import org.junit.Test;
+
+public class NioZipEncodingTest {
+
+    private static final String UMLAUTS = "\u00e4\u00f6\u00fc";
+
+    @Test
+    public void umlautToUTF16BE() {
+        NioZipEncoding e = new NioZipEncoding(StandardCharsets.UTF_16BE, false);
+        ByteBuffer bb = e.encode(UMLAUTS);
+        final int off = bb.arrayOffset();
+        byte[] result = Arrays.copyOfRange(bb.array(), off, off + bb.limit() - bb.position());
+        Assert.assertArrayEquals(UMLAUTS.getBytes(StandardCharsets.UTF_16BE), result);
+    }
+
+    @Test
+    public void umlautToUTF8() {
+        NioZipEncoding e = new NioZipEncoding(StandardCharsets.UTF_8, true);
+        ByteBuffer bb = e.encode("\u00e4\u00f6\u00fc");
+        final int off = bb.arrayOffset();
+        byte[] result = Arrays.copyOfRange(bb.array(), off, off + bb.limit() - bb.position());
+        Assert.assertArrayEquals(UMLAUTS.getBytes(StandardCharsets.UTF_8), result);
+    }
+
+    @Test
+    public void umlautToISO88591() {
+        NioZipEncoding e = new NioZipEncoding(StandardCharsets.ISO_8859_1, true);
+        ByteBuffer bb = e.encode("\u00e4\u00f6\u00fc");
+        final int off = bb.arrayOffset();
+        byte[] result = Arrays.copyOfRange(bb.array(), off, off + bb.limit() - bb.position());
+        Assert.assertArrayEquals(UMLAUTS.getBytes(StandardCharsets.ISO_8859_1), result);
+    }
+
+    @Test
+    public void unmappableUmlauts() {
+        NioZipEncoding e = new NioZipEncoding(StandardCharsets.US_ASCII, false);
+        ByteBuffer bb = e.encode("\u00e4\u00f6\u00fc");
+        final int off = bb.arrayOffset();
+        byte[] result = Arrays.copyOfRange(bb.array(), off, off + bb.limit() - bb.position());
+        Assert.assertEquals("%U00E4%U00F6%U00FC", new String(result, StandardCharsets.US_ASCII));
+    }
+
+    private static final String RAINBOW_EMOJI = "\ud83c\udf08";
+
+    @Test
+    public void unmappableRainbowEmoji() {
+        NioZipEncoding e = new NioZipEncoding(StandardCharsets.US_ASCII, false);
+        ByteBuffer bb = e.encode(RAINBOW_EMOJI);
+        final int off = bb.arrayOffset();
+        byte[] result = Arrays.copyOfRange(bb.array(), off, off + bb.limit() - bb.position());
+        Assert.assertEquals("%UD83C%UDF08", new String(result, StandardCharsets.US_ASCII));
+    }
+
+    @Test
+    public void rainbowEmojiToSurrogatePairUTF16() {
+        NioZipEncoding e = new NioZipEncoding(StandardCharsets.UTF_16BE, false);
+        ByteBuffer bb = e.encode(RAINBOW_EMOJI);
+        final int off = bb.arrayOffset();
+        byte[] result = Arrays.copyOfRange(bb.array(), off, off + bb.limit() - bb.position());
+        Assert.assertArrayEquals(RAINBOW_EMOJI.getBytes(StandardCharsets.UTF_16BE), result);
+    }
+
+    @Test
+    public void partialSurrogatePair() {
+        NioZipEncoding e = new NioZipEncoding(StandardCharsets.US_ASCII, false);
+        ByteBuffer bb = e.encode("\ud83c");
+        final int off = bb.arrayOffset();
+        byte[] result = Arrays.copyOfRange(bb.array(), off, off + bb.limit() - bb.position());
+        Assert.assertEquals(0, result.length);
+    }
+}


[commons-compress] 02/05: avoid NPE warning in Sonar

Posted by bo...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

bodewig pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/commons-compress.git

commit b2f97b2460747c82329e1247c59e74d2cfee1cbd
Author: Stefan Bodewig <bo...@apache.org>
AuthorDate: Fri Aug 23 16:55:00 2019 +0200

    avoid NPE warning in Sonar
---
 .../apache/commons/compress/archivers/zip/ZipArchiveInputStream.java  | 4 ++--
 1 file changed, 2 insertions(+), 2 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 5871598..5b711dd 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
@@ -393,10 +393,10 @@ public class ZipArchiveInputStream extends ArchiveInputStream implements InputSt
         current.usesZip64 = z64 != null;
         if (!current.hasDataDescriptor) {
             if (z64 != null // same as current.usesZip64 but avoids NPE warning
-                    && (cSize.equals(ZipLong.ZIP64_MAGIC) || size.equals(ZipLong.ZIP64_MAGIC)) ) {
+                    && (ZipLong.ZIP64_MAGIC.equals(cSize) || ZipLong.ZIP64_MAGIC.equals(size)) ) {
                 current.entry.setCompressedSize(z64.getCompressedSize().getLongValue());
                 current.entry.setSize(z64.getSize().getLongValue());
-            } else {
+            } else if (cSize != null && size != null) {
                 current.entry.setCompressedSize(cSize.getValue());
                 current.entry.setSize(size.getValue());
             }