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 2022/12/10 22:28:28 UTC

[commons-compress] branch master updated (0d6ccaaf -> 73aa175e)

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

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


    from 0d6ccaaf  Use switch instead. (#298)
     new 1d1a28f9 Remove duplicate conditions. Use switch instead. #298
     new 73aa175e Use try-with-resources

The 2 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:
 src/changes/changes.xml                            | 11 +++----
 .../commons/compress/archivers/ArTestCase.java     | 34 ++++++++--------------
 2 files changed, 18 insertions(+), 27 deletions(-)


[commons-compress] 01/02: Remove duplicate conditions. Use switch instead. #298

Posted by gg...@apache.org.
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 1d1a28f96c464ce3b9486ecc517806f2db3968ac
Author: Gary Gregory <ga...@gmail.com>
AuthorDate: Sat Dec 10 17:28:19 2022 -0500

    Remove duplicate conditions. Use switch instead. #298
---
 src/changes/changes.xml | 11 ++++++-----
 1 file changed, 6 insertions(+), 5 deletions(-)

diff --git a/src/changes/changes.xml b/src/changes/changes.xml
index f8e2afa0..6807a8f1 100644
--- a/src/changes/changes.xml
+++ b/src/changes/changes.xml
@@ -44,11 +44,12 @@ The <action> type attribute can be add,update,fix,remove.
   <body>
     <release version="1.23" date="not released">
       <!-- FIX -->
-      <action type="update" dev="ggregory" due-to="CodeQL, Gary Gregory">Implicit narrowing conversion in compound assignment.</action>
-      <action type="update" dev="ggregory" due-to="CodeQL, Gary Gregory">Avoid NPE in FileNameUtils.getBaseName(Path) for paths with zero elements like root paths.</action>
-      <action type="update" dev="ggregory" due-to="CodeQL, Gary Gregory">Avoid NPE in FileNameUtils.getExtension(Path) for paths with zero elements like root paths.</action>
-      <action type="update" dev="ggregory" due-to="Gary Gregory">LZMA2Decoder.decode() looses original exception.</action>
-      <action type="update" dev="ggregory" due-to="Arturo Bernal">Extract conditions and avoid duplicate code. #297.</action>
+      <action type="fix" dev="ggregory" due-to="CodeQL, Gary Gregory">Implicit narrowing conversion in compound assignment.</action>
+      <action type="fix" dev="ggregory" due-to="CodeQL, Gary Gregory">Avoid NPE in FileNameUtils.getBaseName(Path) for paths with zero elements like root paths.</action>
+      <action type="fix" dev="ggregory" due-to="CodeQL, Gary Gregory">Avoid NPE in FileNameUtils.getExtension(Path) for paths with zero elements like root paths.</action>
+      <action type="fix" dev="ggregory" due-to="Gary Gregory">LZMA2Decoder.decode() looses original exception.</action>
+      <action type="fix" dev="ggregory" due-to="Arturo Bernal">Extract conditions and avoid duplicate code. #297.</action>
+      <action type="fix" dev="ggregory" due-to="Arturo Bernal">Remove duplicate conditions. Use switch instead. #298.</action>
       <!-- ADD -->
       <action type="add" issue="COMPRESS-614" dev="ggregory" due-to="Andre Brait, Gary Gregory">Use FileTime for time fields in SevenZipArchiveEntry #256.</action>
       <action type="add" issue="COMPRESS-621" dev="ggregory" due-to="Glavo">Fix calculation the offset of the first zip central directory entry #334.</action>


[commons-compress] 02/02: Use try-with-resources

Posted by gg...@apache.org.
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 73aa175ed0b1bdb10d968961a0615ad146463788
Author: Gary Gregory <ga...@gmail.com>
AuthorDate: Sat Dec 10 17:28:23 2022 -0500

    Use try-with-resources
---
 .../commons/compress/archivers/ArTestCase.java     | 34 ++++++++--------------
 1 file changed, 12 insertions(+), 22 deletions(-)

diff --git a/src/test/java/org/apache/commons/compress/archivers/ArTestCase.java b/src/test/java/org/apache/commons/compress/archivers/ArTestCase.java
index 9145ed43..5b4b432b 100644
--- a/src/test/java/org/apache/commons/compress/archivers/ArTestCase.java
+++ b/src/test/java/org/apache/commons/compress/archivers/ArTestCase.java
@@ -115,25 +115,21 @@ public final class ArTestCase extends AbstractTestCase {
             out.close();
         }
 
-        assertEquals(8
-                     + 60 + file1.length() + (file1.length() % 2)
-                     + 60 + file2.length() + (file2.length() % 2),
-                     output.length());
+        assertEquals(8 + 60 + file1.length() + (file1.length() % 2) + 60 + file2.length() + (file2.length() % 2), output.length());
 
         final File output2 = new File(dir, "bla2.ar");
 
         int copied = 0;
         int deleted = 0;
 
-        {
-            // remove all but one file
+        // remove all but one file
 
-            final InputStream is = Files.newInputStream(output.toPath());
-            final OutputStream os = Files.newOutputStream(output2.toPath());
-            final ArchiveOutputStream aos = new ArchiveStreamFactory().createArchiveOutputStream("ar", os);
-            final ArchiveInputStream ais = new ArchiveStreamFactory().createArchiveInputStream(new BufferedInputStream(is));
-            while(true) {
-                final ArArchiveEntry entry = (ArArchiveEntry)ais.getNextEntry();
+        try (OutputStream os = Files.newOutputStream(output2.toPath());
+                InputStream is = Files.newInputStream(output.toPath());
+                ArchiveOutputStream aos = new ArchiveStreamFactory().createArchiveOutputStream("ar", os);
+                ArchiveInputStream ais = new ArchiveStreamFactory().createArchiveInputStream(new BufferedInputStream(is))) {
+            while (true) {
+                final ArArchiveEntry entry = (ArArchiveEntry) ais.getNextEntry();
                 if (entry == null) {
                     break;
                 }
@@ -149,17 +145,11 @@ public final class ArTestCase extends AbstractTestCase {
                 }
 
             }
-            ais.close();
-            aos.close();
-            is.close();
-            os.close();
         }
 
         assertEquals(1, copied);
         assertEquals(1, deleted);
-        assertEquals(8
-                     + 60 + file1.length() + (file1.length() % 2),
-                     output2.length());
+        assertEquals(8 + 60 + file1.length() + (file1.length() % 2), output2.length());
 
         long files = 0;
         long sum = 0;
@@ -167,15 +157,15 @@ public final class ArTestCase extends AbstractTestCase {
         {
             final InputStream is = Files.newInputStream(output2.toPath());
             final ArchiveInputStream ais = new ArchiveStreamFactory().createArchiveInputStream(new BufferedInputStream(is));
-            while(true) {
-                final ArArchiveEntry entry = (ArArchiveEntry)ais.getNextEntry();
+            while (true) {
+                final ArArchiveEntry entry = (ArArchiveEntry) ais.getNextEntry();
                 if (entry == null) {
                     break;
                 }
 
                 IOUtils.copy(ais, new ByteArrayOutputStream());
 
-                sum +=  entry.getLength();
+                sum += entry.getLength();
                 files++;
             }
             ais.close();