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/01/23 11:36:04 UTC

[commons-compress] branch master updated (770ea82a -> 33d3833b)

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 770ea82a [COMPRESS-638] The GzipCompressorOutputStream#writeHeader() uses ISO_8859_1 to write the file name and comment.
     new c11e6332 Reuse stock functional interfaces
     new d01607cd Use try-with-resources
     new 33d3833b Merge branch 'master' of https://gitbox.apache.org/repos/asf/commons-compress.git

The 3 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:
 .../zip/ParallelScatterZipCreatorTest.java         | 82 ++++++++++++----------
 1 file changed, 45 insertions(+), 37 deletions(-)


[commons-compress] 01/03: Reuse stock functional interfaces

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 c11e633274cbe3314daf87d2ea52659daa611b19
Author: Gary Gregory <ga...@gmail.com>
AuthorDate: Mon Jan 23 06:29:54 2023 -0500

    Reuse stock functional interfaces
---
 .../archivers/zip/ParallelScatterZipCreatorTest.java         | 12 ++++++++----
 1 file changed, 8 insertions(+), 4 deletions(-)

diff --git a/src/test/java/org/apache/commons/compress/archivers/zip/ParallelScatterZipCreatorTest.java b/src/test/java/org/apache/commons/compress/archivers/zip/ParallelScatterZipCreatorTest.java
index cadfb2ac..4e7e7793 100644
--- a/src/test/java/org/apache/commons/compress/archivers/zip/ParallelScatterZipCreatorTest.java
+++ b/src/test/java/org/apache/commons/compress/archivers/zip/ParallelScatterZipCreatorTest.java
@@ -38,6 +38,8 @@ import java.util.Map;
 import java.util.concurrent.Callable;
 import java.util.concurrent.ExecutorService;
 import java.util.concurrent.Executors;
+import java.util.function.Consumer;
+import java.util.function.Function;
 import java.util.zip.Deflater;
 import java.util.zip.ZipEntry;
 
@@ -50,12 +52,14 @@ import org.junit.jupiter.api.Test;
 
 public class ParallelScatterZipCreatorTest {
 
-    private interface CallableConsumer {
-        void accept(Callable<? extends ScatterZipOutputStream> c);
+    private interface CallableConsumer extends Consumer<Callable<? extends ScatterZipOutputStream>> {
+        // empty
     }
-    private interface CallableConsumerSupplier {
-        CallableConsumer apply(ParallelScatterZipCreator zipCreator);
+    
+    private interface CallableConsumerSupplier extends Function<ParallelScatterZipCreator, CallableConsumer> {
+        // empty
     }
+    
     private static final long EXPECTED_FILE_SIZE = 1024 * 1024; // 1MB
 
     private static final int EXPECTED_FILES_NUMBER = 50;


[commons-compress] 02/03: 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 d01607cd874523ceda431312a11f29fd8f7c9b21
Author: Gary Gregory <ga...@gmail.com>
AuthorDate: Mon Jan 23 06:35:39 2023 -0500

    Use try-with-resources
---
 .../zip/ParallelScatterZipCreatorTest.java         | 74 ++++++++++++----------
 1 file changed, 39 insertions(+), 35 deletions(-)

diff --git a/src/test/java/org/apache/commons/compress/archivers/zip/ParallelScatterZipCreatorTest.java b/src/test/java/org/apache/commons/compress/archivers/zip/ParallelScatterZipCreatorTest.java
index 4e7e7793..172f2864 100644
--- a/src/test/java/org/apache/commons/compress/archivers/zip/ParallelScatterZipCreatorTest.java
+++ b/src/test/java/org/apache/commons/compress/archivers/zip/ParallelScatterZipCreatorTest.java
@@ -55,11 +55,11 @@ public class ParallelScatterZipCreatorTest {
     private interface CallableConsumer extends Consumer<Callable<? extends ScatterZipOutputStream>> {
         // empty
     }
-    
+
     private interface CallableConsumerSupplier extends Function<ParallelScatterZipCreator, CallableConsumer> {
         // empty
     }
-    
+
     private static final long EXPECTED_FILE_SIZE = 1024 * 1024; // 1MB
 
     private static final int EXPECTED_FILES_NUMBER = 50;
@@ -111,19 +111,21 @@ public class ParallelScatterZipCreatorTest {
     }
 
     private void callableApiWithTestFiles(final CallableConsumerSupplier consumerSupplier, final int compressionLevel) throws Exception {
-        final ZipArchiveOutputStream zos = new ZipArchiveOutputStream(result);
-        zos.setEncoding("UTF-8");
-        final ExecutorService es = Executors.newFixedThreadPool(1);
+        final ParallelScatterZipCreator zipCreator;
+        final Map<String, byte[]> entries;
+        try (ZipArchiveOutputStream zos = new ZipArchiveOutputStream(result)) {
+            zos.setEncoding("UTF-8");
+            final ExecutorService es = Executors.newFixedThreadPool(1);
 
-        final ScatterGatherBackingStoreSupplier supp = () -> new FileBasedScatterGatherBackingStore(tmp = File.createTempFile("parallelscatter", "n1"));
+            final ScatterGatherBackingStoreSupplier supp = () -> new FileBasedScatterGatherBackingStore(tmp = File.createTempFile("parallelscatter", "n1"));
 
-        final ParallelScatterZipCreator zipCreator = new ParallelScatterZipCreator(es, supp, compressionLevel);
-        final Map<String, byte[]> entries = writeTestFilesAsCallable(zipCreator, consumerSupplier.apply(zipCreator));
-        zipCreator.writeTo(zos);
-        zos.close();
+            zipCreator = new ParallelScatterZipCreator(es, supp, compressionLevel);
+            entries = writeTestFilesAsCallable(zipCreator, consumerSupplier.apply(zipCreator));
+            zipCreator.writeTo(zos);
+        }
 
         // validate the content of the compressed files
-        try (final ZipFile zf = new ZipFile(result)) {
+        try (ZipFile zf = new ZipFile(result)) {
             final Enumeration<ZipArchiveEntry> entriesInPhysicalOrder = zf.getEntriesInPhysicalOrder();
             while (entriesInPhysicalOrder.hasMoreElements()) {
                 final ZipArchiveEntry zipArchiveEntry = entriesInPhysicalOrder.nextElement();
@@ -153,39 +155,41 @@ public class ParallelScatterZipCreatorTest {
     public void concurrentCustomTempFolder()
             throws Exception {
         result = File.createTempFile("parallelScatterGather1", "");
-        final ZipArchiveOutputStream zos = new ZipArchiveOutputStream(result);
-        zos.setEncoding("UTF-8");
-
-        // Formatter:off
-        final Path dir = Paths.get("target/custom-temp-dir");
-        Files.createDirectories(dir);
-        final ParallelScatterZipCreator zipCreator = new ParallelScatterZipCreator(
-                Executors.newFixedThreadPool(Runtime.getRuntime().availableProcessors()),
-                new DefaultBackingStoreSupplier(dir));
-        // Formatter:on
-
-        final Map<String, byte[]> entries = writeEntries(zipCreator);
-        zipCreator.writeTo(zos);
-        zos.close();
+        final ParallelScatterZipCreator zipCreator;
+        final Map<String, byte[]> entries;
+        try (ZipArchiveOutputStream zos = new ZipArchiveOutputStream(result)) {
+            zos.setEncoding("UTF-8");
+
+            // Formatter:off
+            final Path dir = Paths.get("target/custom-temp-dir");
+            Files.createDirectories(dir);
+            zipCreator = new ParallelScatterZipCreator(Executors.newFixedThreadPool(Runtime.getRuntime().availableProcessors()),
+                    new DefaultBackingStoreSupplier(dir));
+            // Formatter:on
+
+            entries = writeEntries(zipCreator);
+            zipCreator.writeTo(zos);
+        }
         removeEntriesFoundInZipFile(result, entries);
         assertTrue(entries.isEmpty());
-        assertNotNull( zipCreator.getStatisticsMessage());
+        assertNotNull(zipCreator.getStatisticsMessage());
     }
 
     @Test
-    public void concurrentDefaultTempFolder()
-            throws Exception {
+    public void concurrentDefaultTempFolder() throws Exception {
         result = File.createTempFile("parallelScatterGather1", "");
-        final ZipArchiveOutputStream zos = new ZipArchiveOutputStream(result);
-        zos.setEncoding("UTF-8");
-        final ParallelScatterZipCreator zipCreator = new ParallelScatterZipCreator();
+        final ParallelScatterZipCreator zipCreator;
+        final Map<String, byte[]> entries;
+        try (ZipArchiveOutputStream zos = new ZipArchiveOutputStream(result)) {
+            zos.setEncoding("UTF-8");
+            zipCreator = new ParallelScatterZipCreator();
 
-        final Map<String, byte[]> entries = writeEntries(zipCreator);
-        zipCreator.writeTo(zos);
-        zos.close();
+            entries = writeEntries(zipCreator);
+            zipCreator.writeTo(zos);
+        }
         removeEntriesFoundInZipFile(result, entries);
         assertTrue(entries.isEmpty());
-        assertNotNull( zipCreator.getStatisticsMessage());
+        assertNotNull(zipCreator.getStatisticsMessage());
     }
 
     private ZipArchiveEntry createZipArchiveEntry(final Map<String, byte[]> entries, final int i, final byte[] payloadBytes) {


[commons-compress] 03/03: Merge branch 'master' of https://gitbox.apache.org/repos/asf/commons-compress.git

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 33d3833b9fb9e0c392fb42efa69d2b24d01384b2
Merge: d01607cd 770ea82a
Author: Gary Gregory <ga...@gmail.com>
AuthorDate: Mon Jan 23 06:35:47 2023 -0500

    Merge branch 'master' of https://gitbox.apache.org/repos/asf/commons-compress.git

 src/changes/changes.xml                            |  5 ++++
 .../gzip/GzipCompressorOutputStream.java           | 29 +++++++++++++++++++---
 .../gzip/GzipCompressorOutputStreamTest.java       | 14 +++++------
 3 files changed, 38 insertions(+), 10 deletions(-)