You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by gg...@apache.org on 2023/05/04 15:46:25 UTC

[commons-compress] 03/04: Reuse FilterInputStream

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

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

commit f505162e5c10e14ca18a4a79d1916a68c370c8ba
Author: Gary Gregory <ga...@gmail.com>
AuthorDate: Thu May 4 10:58:01 2023 -0400

    Reuse FilterInputStream
---
 .../compress/archivers/zip/ExplodingInputStream.java | 20 +++++---------------
 1 file changed, 5 insertions(+), 15 deletions(-)

diff --git a/src/main/java/org/apache/commons/compress/archivers/zip/ExplodingInputStream.java b/src/main/java/org/apache/commons/compress/archivers/zip/ExplodingInputStream.java
index 31728b71..77784602 100644
--- a/src/main/java/org/apache/commons/compress/archivers/zip/ExplodingInputStream.java
+++ b/src/main/java/org/apache/commons/compress/archivers/zip/ExplodingInputStream.java
@@ -19,6 +19,7 @@
 
 package org.apache.commons.compress.archivers.zip;
 
+import java.io.FilterInputStream;
 import java.io.IOException;
 import java.io.InputStream;
 
@@ -38,10 +39,7 @@ import org.apache.commons.compress.utils.InputStreamStatistics;
  *
  * @since 1.7
  */
-class ExplodingInputStream extends InputStream implements InputStreamStatistics {
-
-    /** The underlying stream containing the compressed data */
-    private final InputStream in;
+class ExplodingInputStream extends FilterInputStream implements InputStreamStatistics {
 
     /** The stream of bits read from the input stream */
     private BitStream bits;
@@ -71,7 +69,7 @@ class ExplodingInputStream extends InputStream implements InputStreamStatistics
     private long treeSizes;
 
     /**
-     * Create a new stream decompressing the content of the specified stream
+     * Constructs a new stream decompressing the content of the specified stream
      * using the explode algorithm.
      *
      * @param dictionarySize the size of the sliding dictionary (4096 or 8192)
@@ -79,6 +77,7 @@ class ExplodingInputStream extends InputStream implements InputStreamStatistics
      * @param in             the compressed data stream
      */
     public ExplodingInputStream(final int dictionarySize, final int numberOfTrees, final InputStream in) {
+        super(in);
         if (dictionarySize != 4096 && dictionarySize != 8192) {
             throw new IllegalArgumentException("The dictionary size must be 4096 or 8192");
         }
@@ -88,19 +87,10 @@ class ExplodingInputStream extends InputStream implements InputStreamStatistics
         this.dictionarySize = dictionarySize;
         this.numberOfTrees = numberOfTrees;
         this.minimumMatchLength = numberOfTrees;
-        this.in = in;
-    }
-
-    /**
-     * @since 1.17
-     */
-    @Override
-    public void close() throws IOException {
-        in.close();
     }
 
     /**
-     * Fill the sliding dictionary with more data.
+     * Fills the sliding dictionary with more data.
      * @throws IOException on error.
      */
     private void fillBuffer() throws IOException {