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 2021/12/26 17:07:40 UTC

[commons-compress] branch master updated: Trade this for underscores in constructor.

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


The following commit(s) were added to refs/heads/master by this push:
     new bd6c71e  Trade this for underscores in constructor.
bd6c71e is described below

commit bd6c71e2bfaa95cbaaa9ddc18d8775d6703f64ea
Author: Gary Gregory <ga...@gmail.com>
AuthorDate: Sun Dec 26 12:07:34 2021 -0500

    Trade this for underscores in constructor.
    
    Better internal name.
---
 .../archivers/zip/ZipArchiveOutputStream.java      | 70 +++++++++++-----------
 1 file changed, 35 insertions(+), 35 deletions(-)

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 d3784ae..abcccf7 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
@@ -248,7 +248,7 @@ public class ZipArchiveOutputStream extends ArchiveOutputStream {
      */
     private final SeekableByteChannel channel;
 
-    private final OutputStream out;
+    private final OutputStream outputStream;
 
     /**
      * whether to use the general purpose bit flag when writing UTF-8
@@ -294,7 +294,7 @@ public class ZipArchiveOutputStream extends ArchiveOutputStream {
      * @param out the outputstream to zip
      */
     public ZipArchiveOutputStream(final OutputStream out) {
-        this.out = out;
+        this.outputStream = out;
         this.channel = null;
         def = new Deflater(level, true);
         streamCompressor = StreamCompressor.create(out, def);
@@ -321,26 +321,26 @@ public class ZipArchiveOutputStream extends ArchiveOutputStream {
      */
     public ZipArchiveOutputStream(final Path file, final OpenOption... options) throws IOException {
         def = new Deflater(level, true);
-        OutputStream o = null;
-        SeekableByteChannel _channel = null;
-        StreamCompressor _streamCompressor = null;
+        OutputStream outputStream = null;
+        SeekableByteChannel channel = null;
+        StreamCompressor streamCompressor = null;
         try {
-            _channel = Files.newByteChannel(file,
+            channel = Files.newByteChannel(file,
                 EnumSet.of(StandardOpenOption.CREATE, StandardOpenOption.WRITE,
                            StandardOpenOption.READ,
                            StandardOpenOption.TRUNCATE_EXISTING));
             // will never get opened properly when an exception is thrown so doesn't need to get closed
-            _streamCompressor = StreamCompressor.create(_channel, def); //NOSONAR
+            streamCompressor = StreamCompressor.create(channel, def); //NOSONAR
         } catch (final IOException e) { // NOSONAR
-            IOUtils.closeQuietly(_channel);
-            _channel = null;
-            o = Files.newOutputStream(file, options);
-            _streamCompressor = StreamCompressor.create(o, def);
-        }
-        out = o;
-        channel = _channel;
-        streamCompressor = _streamCompressor;
-        isSplitZip = false;
+            IOUtils.closeQuietly(channel);
+            channel = null;
+            outputStream = Files.newOutputStream(file, options);
+            streamCompressor = StreamCompressor.create(outputStream, def);
+        }
+        this.outputStream = outputStream;
+        this.channel = channel;
+        this.streamCompressor = streamCompressor;
+        this.isSplitZip = false;
     }
 
     /**
@@ -386,8 +386,8 @@ public class ZipArchiveOutputStream extends ArchiveOutputStream {
      */
     public ZipArchiveOutputStream(final Path path, final long zipSplitSize) throws IOException {
         def = new Deflater(level, true);
-        this.out = new ZipSplitOutputStream(path, zipSplitSize);
-        streamCompressor = StreamCompressor.create(this.out, def);
+        this.outputStream = new ZipSplitOutputStream(path, zipSplitSize);
+        streamCompressor = StreamCompressor.create(this.outputStream, def);
         channel = null;
         isSplitZip = true;
     }
@@ -408,7 +408,7 @@ public class ZipArchiveOutputStream extends ArchiveOutputStream {
         this.channel = channel;
         def = new Deflater(level, true);
         streamCompressor = StreamCompressor.create(channel, def);
-        out = null;
+        outputStream = null;
         isSplitZip = false;
     }
 
@@ -569,7 +569,7 @@ public class ZipArchiveOutputStream extends ArchiveOutputStream {
         if (isSplitZip) {
             // when creating a split zip, the offset should be
             // the offset to the corresponding segment disk
-            final ZipSplitOutputStream zipSplitOutputStream = (ZipSplitOutputStream)this.out;
+            final ZipSplitOutputStream zipSplitOutputStream = (ZipSplitOutputStream)this.outputStream;
             cdOffset = zipSplitOutputStream.getCurrentSplitSegmentBytesWritten();
             cdDiskNumberStart = zipSplitOutputStream.getCurrentSplitSegmentIndex();
         }
@@ -597,7 +597,7 @@ public class ZipArchiveOutputStream extends ArchiveOutputStream {
         streamCompressor.close();
         if (isSplitZip) {
             // trigger the ZipSplitOutputStream to write the final split segment
-            out.close();
+            outputStream.close();
         }
         finished = true;
     }
@@ -1132,8 +1132,8 @@ public class ZipArchiveOutputStream extends ArchiveOutputStream {
      */
     @Override
     public void flush() throws IOException {
-        if (out != null) {
-            out.flush();
+        if (outputStream != null) {
+            outputStream.flush();
         }
     }
 
@@ -1194,7 +1194,7 @@ public class ZipArchiveOutputStream extends ArchiveOutputStream {
         if (isSplitZip) {
             // when creating a split zip, the offset should be
             // the offset to the corresponding segment disk
-            final ZipSplitOutputStream splitOutputStream = (ZipSplitOutputStream)this.out;
+            final ZipSplitOutputStream splitOutputStream = (ZipSplitOutputStream)this.outputStream;
             ze.setDiskNumberStart(splitOutputStream.getCurrentSplitSegmentIndex());
             localHeaderStart = splitOutputStream.getCurrentSplitSegmentBytesWritten();
         }
@@ -1401,7 +1401,7 @@ public class ZipArchiveOutputStream extends ArchiveOutputStream {
         if(isSplitZip) {
             // calculate the disk number for every central file header,
             // this will be used in writing End Of Central Directory and Zip64 End Of Central Directory
-            final int currentSplitSegment = ((ZipSplitOutputStream)this.out).getCurrentSplitSegmentIndex();
+            final int currentSplitSegment = ((ZipSplitOutputStream)this.outputStream).getCurrentSplitSegmentIndex();
             if(numberOfCDInDiskData.get(currentSplitSegment) == null) {
                 numberOfCDInDiskData.put(currentSplitSegment, 1);
             } else {
@@ -1548,7 +1548,7 @@ public class ZipArchiveOutputStream extends ArchiveOutputStream {
      */
     protected void writeCentralDirectoryEnd() throws IOException {
         if(!hasUsedZip64 && isSplitZip) {
-            ((ZipSplitOutputStream)this.out).prepareToWriteUnsplittableContent(eocdLength);
+            ((ZipSplitOutputStream)this.outputStream).prepareToWriteUnsplittableContent(eocdLength);
         }
 
         validateIfZip64IsNeededInEOCD();
@@ -1558,7 +1558,7 @@ public class ZipArchiveOutputStream extends ArchiveOutputStream {
         // number of this disk
         int numberOfThisDisk = 0;
         if(isSplitZip) {
-            numberOfThisDisk = ((ZipSplitOutputStream)this.out).getCurrentSplitSegmentIndex();
+            numberOfThisDisk = ((ZipSplitOutputStream)this.outputStream).getCurrentSplitSegmentIndex();
         }
         writeCounted(ZipShort.getBytes(numberOfThisDisk));
 
@@ -1605,7 +1605,7 @@ public class ZipArchiveOutputStream extends ArchiveOutputStream {
 
         int numberOfThisDisk = 0;
         if (isSplitZip) {
-            numberOfThisDisk = ((ZipSplitOutputStream)this.out).getCurrentSplitSegmentIndex();
+            numberOfThisDisk = ((ZipSplitOutputStream)this.outputStream).getCurrentSplitSegmentIndex();
         }
         if (numberOfThisDisk >= ZIP64_MAGIC_SHORT) {
             throw new Zip64RequiredException(Zip64RequiredException
@@ -1666,7 +1666,7 @@ public class ZipArchiveOutputStream extends ArchiveOutputStream {
         if(isSplitZip) {
             // when creating a split zip, the offset of should be
             // the offset to the corresponding segment disk
-            final ZipSplitOutputStream zipSplitOutputStream = (ZipSplitOutputStream)this.out;
+            final ZipSplitOutputStream zipSplitOutputStream = (ZipSplitOutputStream)this.outputStream;
             offset = zipSplitOutputStream.getCurrentSplitSegmentBytesWritten();
             diskNumberStart = zipSplitOutputStream.getCurrentSplitSegmentIndex();
         }
@@ -1693,7 +1693,7 @@ public class ZipArchiveOutputStream extends ArchiveOutputStream {
         // number of this disk
         int numberOfThisDisk = 0;
         if (isSplitZip) {
-            numberOfThisDisk = ((ZipSplitOutputStream)this.out).getCurrentSplitSegmentIndex();
+            numberOfThisDisk = ((ZipSplitOutputStream)this.outputStream).getCurrentSplitSegmentIndex();
         }
         writeOut(ZipLong.getBytes(numberOfThisDisk));
 
@@ -1726,7 +1726,7 @@ public class ZipArchiveOutputStream extends ArchiveOutputStream {
                     + WORD  /* total number of disks */;
 
             final long unsplittableContentSize = zip64EOCDLOCLength + eocdLength;
-            ((ZipSplitOutputStream)this.out).prepareToWriteUnsplittableContent(unsplittableContentSize);
+            ((ZipSplitOutputStream)this.outputStream).prepareToWriteUnsplittableContent(unsplittableContentSize);
         }
 
         // and now the "ZIP64 end of central directory locator"
@@ -1740,7 +1740,7 @@ public class ZipArchiveOutputStream extends ArchiveOutputStream {
         if(isSplitZip) {
             // the Zip64 End Of Central Directory Locator and the End Of Central Directory must be
             // in the same split disk, it means they must be located in the last disk
-            final int totalNumberOfDisks = ((ZipSplitOutputStream)this.out).getCurrentSplitSegmentIndex() + 1;
+            final int totalNumberOfDisks = ((ZipSplitOutputStream)this.outputStream).getCurrentSplitSegmentIndex() + 1;
             writeOut(ZipLong.getBytes(totalNumberOfDisks));
         } else {
             writeOut(ONE);
@@ -1757,7 +1757,7 @@ public class ZipArchiveOutputStream extends ArchiveOutputStream {
     private boolean shouldUseZip64EOCD() {
         int numberOfThisDisk = 0;
         if(isSplitZip) {
-            numberOfThisDisk = ((ZipSplitOutputStream)this.out).getCurrentSplitSegmentIndex();
+            numberOfThisDisk = ((ZipSplitOutputStream)this.outputStream).getCurrentSplitSegmentIndex();
         }
         final int numOfEntriesOnThisDisk = numberOfCDInDiskData.get(numberOfThisDisk) == null ? 0 : numberOfCDInDiskData.get(numberOfThisDisk);
         return numberOfThisDisk >= ZIP64_MAGIC_SHORT            /* number of this disk */
@@ -1948,8 +1948,8 @@ public class ZipArchiveOutputStream extends ArchiveOutputStream {
                 channel.close();
             }
         } finally {
-            if (out != null) {
-                out.close();
+            if (outputStream != null) {
+                outputStream.close();
             }
         }
     }