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 f102e44a17807199769edbc828bc2d1139cca4e8
Author: Gary Gregory <[email protected]>
AuthorDate: Sat Nov 4 12:05:36 2023 -0400

    Better internal names
---
 .../compressors/pack200/AbstractStreamBridge.java  |  40 ++--
 .../pack200/InMemoryCachingStreamBridge.java       |   2 +-
 .../pack200/Pack200CompressorInputStream.java      | 202 ++++++++++-----------
 .../pack200/Pack200CompressorOutputStream.java     |   2 +-
 .../pack200/TempFileCachingStreamBridge.java       |   2 +-
 5 files changed, 118 insertions(+), 130 deletions(-)

diff --git 
a/src/main/java/org/apache/commons/compress/compressors/pack200/AbstractStreamBridge.java
 
b/src/main/java/org/apache/commons/compress/compressors/pack200/AbstractStreamBridge.java
index 8a1caab7..aebb8c09 100644
--- 
a/src/main/java/org/apache/commons/compress/compressors/pack200/AbstractStreamBridge.java
+++ 
b/src/main/java/org/apache/commons/compress/compressors/pack200/AbstractStreamBridge.java
@@ -25,50 +25,50 @@ import java.io.InputStream;
 import java.io.OutputStream;
 
 /**
- * Provides an InputStream to read all data written to this
- * OutputStream.
+ * Provides an InputStream to read all data written to this OutputStream.
  *
  * @ThreadSafe
  * @since 1.3
  */
 abstract class AbstractStreamBridge extends FilterOutputStream {
-    private InputStream input;
-    private final Object inputLock = new Object();
+
+    private InputStream inputStream;
+    private final Object inputStreamLock = new Object();
 
     protected AbstractStreamBridge() {
         this(null);
     }
 
-    protected AbstractStreamBridge(final OutputStream out) {
-        super(out);
+    protected AbstractStreamBridge(final OutputStream outputStream) {
+        super(outputStream);
     }
 
+    /**
+     * Creates the input view.
+     */
+    abstract InputStream createInputStream() throws IOException;
+
     /**
      * Provides the input view.
      */
-    InputStream getInput() throws IOException {
-        synchronized (inputLock) {
-            if (input == null) {
-                input = getInputView();
+    InputStream getInputStream() throws IOException {
+        synchronized (inputStreamLock) {
+            if (inputStream == null) {
+                inputStream = createInputStream();
             }
         }
-        return input;
+        return inputStream;
     }
 
-    /**
-     * Creates the input view.
-     */
-    abstract InputStream getInputView() throws IOException;
-
     /**
      * Closes input and output and releases all associated resources.
      */
     void stop() throws IOException {
         close();
-        synchronized (inputLock) {
-            if (input != null) {
-                input.close();
-                input = null;
+        synchronized (inputStreamLock) {
+            if (inputStream != null) {
+                inputStream.close();
+                inputStream = null;
             }
         }
     }
diff --git 
a/src/main/java/org/apache/commons/compress/compressors/pack200/InMemoryCachingStreamBridge.java
 
b/src/main/java/org/apache/commons/compress/compressors/pack200/InMemoryCachingStreamBridge.java
index dbe71043..995e3843 100644
--- 
a/src/main/java/org/apache/commons/compress/compressors/pack200/InMemoryCachingStreamBridge.java
+++ 
b/src/main/java/org/apache/commons/compress/compressors/pack200/InMemoryCachingStreamBridge.java
@@ -36,7 +36,7 @@ class InMemoryCachingStreamBridge extends 
AbstractStreamBridge {
     }
 
     @Override
-    InputStream getInputView() throws IOException {
+    InputStream createInputStream() throws IOException {
         return new ByteArrayInputStream(((ByteArrayOutputStream) 
out).toByteArray());
     }
 }
diff --git 
a/src/main/java/org/apache/commons/compress/compressors/pack200/Pack200CompressorInputStream.java
 
b/src/main/java/org/apache/commons/compress/compressors/pack200/Pack200CompressorInputStream.java
index 6beb1356..0940a9ec 100644
--- 
a/src/main/java/org/apache/commons/compress/compressors/pack200/Pack200CompressorInputStream.java
+++ 
b/src/main/java/org/apache/commons/compress/compressors/pack200/Pack200CompressorInputStream.java
@@ -32,32 +32,26 @@ import 
org.apache.commons.compress.utils.CloseShieldFilterInputStream;
 import org.apache.commons.compress.utils.IOUtils;
 
 /**
- * An input stream that decompresses from the Pack200 format to be read
- * as any other stream.
+ * An input stream that decompresses from the Pack200 format to be read as any 
other stream.
  *
- * <p>The {@link CompressorInputStream#getCount getCount} and {@link
- * CompressorInputStream#getBytesRead getBytesRead} methods always
- * return 0.</p>
+ * <p>
+ * The {@link CompressorInputStream#getCount getCount} and {@link 
CompressorInputStream#getBytesRead getBytesRead} methods always return 0.
+ * </p>
  *
  * @NotThreadSafe
  * @since 1.3
  */
 public class Pack200CompressorInputStream extends CompressorInputStream {
-    private static final byte[] CAFE_DOOD = {
-        (byte) 0xCA, (byte) 0xFE, (byte) 0xD0, (byte) 0x0D
-    };
+
+    private static final byte[] CAFE_DOOD = { (byte) 0xCA, (byte) 0xFE, (byte) 
0xD0, (byte) 0x0D };
     private static final int SIG_LENGTH = CAFE_DOOD.length;
 
     /**
-     * Checks if the signature matches what is expected for a pack200
-     * file (0xCAFED00D).
+     * Checks if the signature matches what is expected for a pack200 file 
(0xCAFED00D).
      *
-     * @param signature
-     *            the bytes to check
-     * @param length
-     *            the number of bytes to check
-     * @return true, if this stream is a pack200 compressed stream,
-     * false otherwise
+     * @param signature the bytes to check
+     * @param length    the number of bytes to check
+     * @return true, if this stream is a pack200 compressed stream, false 
otherwise
      */
     public static boolean matches(final byte[] signature, final int length) {
         if (length < SIG_LENGTH) {
@@ -73,157 +67,139 @@ public class Pack200CompressorInputStream extends 
CompressorInputStream {
         return true;
     }
 
-    private final InputStream originalInput;
+    private final InputStream originalInputStream;
 
     private final AbstractStreamBridge abstractStreamBridge;
 
     /**
-     * Decompresses the given file, caching the decompressed data in
-     * memory.
+     * Decompresses the given file, caching the decompressed data in memory.
      *
-     * @param f the file to decompress
+     * @param file the file to decompress
      * @throws IOException if reading fails
      */
-    public Pack200CompressorInputStream(final File f) throws IOException {
-        this(f, Pack200Strategy.IN_MEMORY);
+    public Pack200CompressorInputStream(final File file) throws IOException {
+        this(file, Pack200Strategy.IN_MEMORY);
     }
 
     /**
-     * Decompresses the given file, caching the decompressed data in
-     * memory and using the given properties.
+     * Decompresses the given file, caching the decompressed data in memory 
and using the given properties.
      *
-     * @param f the file to decompress
-     * @param props Pack200 properties to use
+     * @param file     the file to decompress
+     * @param properties Pack200 properties to use
      * @throws IOException if reading fails
      */
-    public Pack200CompressorInputStream(final File f,
-                                        final Map<String, String> props)
-        throws IOException {
-        this(f, Pack200Strategy.IN_MEMORY, props);
+    public Pack200CompressorInputStream(final File file, final Map<String, 
String> properties) throws IOException {
+        this(file, Pack200Strategy.IN_MEMORY, properties);
     }
 
     /**
-     * Decompresses the given file using the given strategy to cache
-     * the results.
+     * Decompresses the given file using the given strategy to cache the 
results.
      *
-     * @param f the file to decompress
+     * @param file    the file to decompress
      * @param mode the strategy to use
      * @throws IOException if reading fails
      */
-    public Pack200CompressorInputStream(final File f, final Pack200Strategy 
mode)
-        throws IOException {
-        this(null, f, mode, null);
+    public Pack200CompressorInputStream(final File file, final Pack200Strategy 
mode) throws IOException {
+        this(null, file, mode, null);
     }
 
     /**
-     * Decompresses the given file using the given strategy to cache
-     * the results and the given properties.
+     * Decompresses the given file using the given strategy to cache the 
results and the given properties.
      *
-     * @param f the file to decompress
-     * @param mode the strategy to use
-     * @param props Pack200 properties to use
+     * @param file     the file to decompress
+     * @param mode  the strategy to use
+     * @param properties Pack200 properties to use
      * @throws IOException if reading fails
      */
-    public Pack200CompressorInputStream(final File f, final Pack200Strategy 
mode,
-                                        final Map<String, String> props)
-        throws IOException {
-        this(null, f, mode, props);
+    public Pack200CompressorInputStream(final File file, final Pack200Strategy 
mode, final Map<String, String> properties) throws IOException {
+        this(null, file, mode, properties);
     }
 
     /**
-     * Decompresses the given stream, caching the decompressed data in
-     * memory.
+     * Decompresses the given stream, caching the decompressed data in memory.
      *
-     * <p>When reading from a file the File-arg constructor may
-     * provide better performance.</p>
+     * <p>
+     * When reading from a file the File-arg constructor may provide better 
performance.
+     * </p>
      *
-     * @param in the InputStream from which this object should be created
+     * @param inputStream the InputStream from which this object should be 
created
      * @throws IOException if reading fails
      */
-    public Pack200CompressorInputStream(final InputStream in)
-        throws IOException {
-        this(in, Pack200Strategy.IN_MEMORY);
+    public Pack200CompressorInputStream(final InputStream inputStream) throws 
IOException {
+        this(inputStream, Pack200Strategy.IN_MEMORY);
     }
 
-    private Pack200CompressorInputStream(final InputStream in, final File f,
-                                         final Pack200Strategy mode,
-                                         final Map<String, String> props)
+    private Pack200CompressorInputStream(final InputStream inputStream, final 
File file, final Pack200Strategy mode, final Map<String, String> properties)
             throws IOException {
-        originalInput = in;
-        abstractStreamBridge = mode.newStreamBridge();
+        this.originalInputStream = inputStream;
+        this.abstractStreamBridge = mode.newStreamBridge();
         try (final JarOutputStream jarOut = new 
JarOutputStream(abstractStreamBridge)) {
-            final Pack200.Unpacker u = Pack200.newUnpacker();
-            if (props != null) {
-                u.properties().putAll(props);
+            final Pack200.Unpacker unpacker = Pack200.newUnpacker();
+            if (properties != null) {
+                unpacker.properties().putAll(properties);
             }
-            if (f == null) {
+            if (file == null) {
                 // unpack would close this stream but we want to give the call 
site more control
                 // TODO unpack should not close its given stream.
-                try (final CloseShieldFilterInputStream closeShield = new 
CloseShieldFilterInputStream(in)) {
-                    u.unpack(closeShield, jarOut);
+                try (final CloseShieldFilterInputStream closeShield = new 
CloseShieldFilterInputStream(inputStream)) {
+                    unpacker.unpack(closeShield, jarOut);
                 }
             } else {
-                u.unpack(f, jarOut);
+                unpacker.unpack(file, jarOut);
             }
         }
     }
 
     /**
-     * Decompresses the given stream, caching the decompressed data in
-     * memory and using the given properties.
+     * Decompresses the given stream, caching the decompressed data in memory 
and using the given properties.
      *
-     * <p>When reading from a file the File-arg constructor may
-     * provide better performance.</p>
+     * <p>
+     * When reading from a file the File-arg constructor may provide better 
performance.
+     * </p>
      *
-     * @param in the InputStream from which this object should be created
-     * @param props Pack200 properties to use
+     * @param inputStream    the InputStream from which this object should be 
created
+     * @param properties Pack200 properties to use
      * @throws IOException if reading fails
      */
-    public Pack200CompressorInputStream(final InputStream in,
-                                        final Map<String, String> props)
-        throws IOException {
-        this(in, Pack200Strategy.IN_MEMORY, props);
+    public Pack200CompressorInputStream(final InputStream inputStream, final 
Map<String, String> properties) throws IOException {
+        this(inputStream, Pack200Strategy.IN_MEMORY, properties);
     }
 
     /**
-     * Decompresses the given stream using the given strategy to cache
-     * the results.
+     * Decompresses the given stream using the given strategy to cache the 
results.
      *
-     * <p>When reading from a file the File-arg constructor may
-     * provide better performance.</p>
+     * <p>
+     * When reading from a file the File-arg constructor may provide better 
performance.
+     * </p>
      *
-     * @param in the InputStream from which this object should be created
+     * @param inputStream   the InputStream from which this object should be 
created
      * @param mode the strategy to use
      * @throws IOException if reading fails
      */
-    public Pack200CompressorInputStream(final InputStream in,
-                                        final Pack200Strategy mode)
-        throws IOException {
-        this(in, null, mode, null);
+    public Pack200CompressorInputStream(final InputStream inputStream, final 
Pack200Strategy mode) throws IOException {
+        this(inputStream, null, mode, null);
     }
 
     /**
-     * Decompresses the given stream using the given strategy to cache
-     * the results and the given properties.
+     * Decompresses the given stream using the given strategy to cache the 
results and the given properties.
      *
-     * <p>When reading from a file the File-arg constructor may
-     * provide better performance.</p>
+     * <p>
+     * When reading from a file the File-arg constructor may provide better 
performance.
+     * </p>
      *
-     * @param in the InputStream from which this object should be created
-     * @param mode the strategy to use
-     * @param props Pack200 properties to use
+     * @param inputStream    the InputStream from which this object should be 
created
+     * @param mode  the strategy to use
+     * @param properties Pack200 properties to use
      * @throws IOException if reading fails
      */
-    public Pack200CompressorInputStream(final InputStream in,
-                                        final Pack200Strategy mode,
-                                        final Map<String, String> props)
-        throws IOException {
-        this(in, null, mode, props);
+    public Pack200CompressorInputStream(final InputStream inputStream, final 
Pack200Strategy mode, final Map<String, String> properties) throws IOException {
+        this(inputStream, null, mode, properties);
     }
 
+    @SuppressWarnings("resource") // Does not allocate
     @Override
     public int available() throws IOException {
-        return abstractStreamBridge.getInput().available();
+        return getInputStream().available();
     }
 
     @Override
@@ -231,51 +207,63 @@ public class Pack200CompressorInputStream extends 
CompressorInputStream {
         try {
             abstractStreamBridge.stop();
         } finally {
-            if (originalInput != null) {
-                originalInput.close();
+            if (originalInputStream != null) {
+                originalInputStream.close();
             }
         }
     }
 
+    private InputStream getInputStream() throws IOException {
+        return abstractStreamBridge.getInputStream();
+    }
+
+    @SuppressWarnings("resource") // Does not allocate
     @Override
     public synchronized void mark(final int limit) {
         try {
-            abstractStreamBridge.getInput().mark(limit);
+            getInputStream().mark(limit);
         } catch (final IOException ex) {
-            throw new UncheckedIOException(ex); //NOSONAR
+            throw new UncheckedIOException(ex); // NOSONAR
         }
     }
 
+    @SuppressWarnings("resource") // Does not allocate
     @Override
     public boolean markSupported() {
         try {
-            return abstractStreamBridge.getInput().markSupported();
+            return getInputStream().markSupported();
         } catch (final IOException ex) { // NOSONAR
             return false;
         }
     }
 
+    @SuppressWarnings("resource") // Does not allocate
     @Override
     public int read() throws IOException {
-        return abstractStreamBridge.getInput().read();
+        return getInputStream().read();
     }
 
+    @SuppressWarnings("resource") // Does not allocate
     @Override
     public int read(final byte[] b) throws IOException {
-        return abstractStreamBridge.getInput().read(b);
+        return getInputStream().read(b);
     }
 
+    @SuppressWarnings("resource") // Does not allocate
     @Override
     public int read(final byte[] b, final int off, final int count) throws 
IOException {
-        return abstractStreamBridge.getInput().read(b, off, count);
+        return getInputStream().read(b, off, count);
     }
+
+    @SuppressWarnings("resource") // Does not allocate
     @Override
     public synchronized void reset() throws IOException {
-        abstractStreamBridge.getInput().reset();
+        getInputStream().reset();
     }
 
+    @SuppressWarnings("resource") // Does not allocate
     @Override
     public long skip(final long count) throws IOException {
-        return IOUtils.skip(abstractStreamBridge.getInput(), count);
+        return IOUtils.skip(getInputStream(), count);
     }
 }
diff --git 
a/src/main/java/org/apache/commons/compress/compressors/pack200/Pack200CompressorOutputStream.java
 
b/src/main/java/org/apache/commons/compress/compressors/pack200/Pack200CompressorOutputStream.java
index c3043eb1..9865e1e8 100644
--- 
a/src/main/java/org/apache/commons/compress/compressors/pack200/Pack200CompressorOutputStream.java
+++ 
b/src/main/java/org/apache/commons/compress/compressors/pack200/Pack200CompressorOutputStream.java
@@ -117,7 +117,7 @@ public class Pack200CompressorOutputStream extends 
CompressorOutputStream {
             if (properties != null) {
                 p.properties().putAll(properties);
             }
-            try (JarInputStream ji = new 
JarInputStream(abstractStreamBridge.getInput())) {
+            try (JarInputStream ji = new 
JarInputStream(abstractStreamBridge.getInputStream())) {
                 p.pack(ji, originalOutput);
             }
         }
diff --git 
a/src/main/java/org/apache/commons/compress/compressors/pack200/TempFileCachingStreamBridge.java
 
b/src/main/java/org/apache/commons/compress/compressors/pack200/TempFileCachingStreamBridge.java
index 3f3601c3..826510a9 100644
--- 
a/src/main/java/org/apache/commons/compress/compressors/pack200/TempFileCachingStreamBridge.java
+++ 
b/src/main/java/org/apache/commons/compress/compressors/pack200/TempFileCachingStreamBridge.java
@@ -43,7 +43,7 @@ class TempFileCachingStreamBridge extends 
AbstractStreamBridge {
 
     @SuppressWarnings("resource") // Caller closes
     @Override
-    InputStream getInputView() throws IOException {
+    InputStream createInputStream() throws IOException {
         out.close();
         return new FilterInputStream(Files.newInputStream(path)) {
             @Override

Reply via email to