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:24 UTC
[commons-compress] 02/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 c9f3ea3d3f2bbb59302ece8b071ae35a9d05c62b
Author: Gary Gregory <ga...@gmail.com>
AuthorDate: Thu May 4 10:33:43 2023 -0400
Reuse FilterInputStream
---
.../commons/compress/archivers/sevenz/Coders.java | 22 ++++------------------
1 file changed, 4 insertions(+), 18 deletions(-)
diff --git a/src/main/java/org/apache/commons/compress/archivers/sevenz/Coders.java b/src/main/java/org/apache/commons/compress/archivers/sevenz/Coders.java
index 241a476c..68650244 100644
--- a/src/main/java/org/apache/commons/compress/archivers/sevenz/Coders.java
+++ b/src/main/java/org/apache/commons/compress/archivers/sevenz/Coders.java
@@ -17,6 +17,7 @@
package org.apache.commons.compress.archivers.sevenz;
import java.io.ByteArrayInputStream;
+import java.io.FilterInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
@@ -114,40 +115,25 @@ class Coders {
}
static class DeflateDecoder extends AbstractCoder {
- static class DeflateDecoderInputStream extends InputStream {
+ static class DeflateDecoderInputStream extends FilterInputStream {
- final InflaterInputStream inflaterInputStream;
Inflater inflater;
public DeflateDecoderInputStream(final InflaterInputStream inflaterInputStream,
final Inflater inflater) {
- this.inflaterInputStream = inflaterInputStream;
+ super(inflaterInputStream);
this.inflater = inflater;
}
@Override
public void close() throws IOException {
try {
- inflaterInputStream.close();
+ super.close();
} finally {
inflater.end();
}
}
- @Override
- public int read() throws IOException {
- return inflaterInputStream.read();
- }
-
- @Override
- public int read(final byte[] b) throws IOException {
- return inflaterInputStream.read(b);
- }
-
- @Override
- public int read(final byte[] b, final int off, final int len) throws IOException {
- return inflaterInputStream.read(b, off, len);
- }
}
static class DeflateDecoderOutputStream extends OutputStream {