You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by bo...@apache.org on 2019/08/08 09:19:44 UTC

[commons-compress] branch master updated (b0777e8 -> c5039b5)

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

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


    from b0777e8  add openjdk13 to travis builds
     new e217582  Substituting 'synchronized' with faster and fully thread-safe collections 'ConcurrentLinkedDeque' and iterators.
     new c5039b5  COMPRESS-485 record second part

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                            |  5 +--
 .../archivers/zip/ParallelScatterZipCreator.java   | 36 +++++++++-------------
 2 files changed, 18 insertions(+), 23 deletions(-)


[commons-compress] 02/02: COMPRESS-485 record second part

Posted by bo...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

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

commit c5039b52e9f92ed6ec96d35a6848240d19244deb
Author: Stefan Bodewig <bo...@apache.org>
AuthorDate: Thu Aug 8 11:19:20 2019 +0200

    COMPRESS-485 record second part
---
 src/changes/changes.xml | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/src/changes/changes.xml b/src/changes/changes.xml
index 47f5b76..cd51c61 100644
--- a/src/changes/changes.xml
+++ b/src/changes/changes.xml
@@ -85,11 +85,12 @@ The <action> type attribute can be add,update,fix,remove.
               issue="COMPRESS-484">
         Update optional library zstd-jni from 1.3.3-3 to 1.4.0-1.
       </action>
-      <action type="update" date="2019-08-07" due-to="Hervé Boutemy"
+      <action type="update" date="2019-08-07"
+              due-to="Hervé Boutemy, Tibor Digana"
               issue="COMPRESS-485">
         ParallelScatterZipCreator now writes the entries to the
         gathered output in the same order they have been added.
-        Github Pull Request #78.
+        Github Pull Requests #78 and #79.
       </action>
     </release>
     <release version="1.18" date="2018-08-16"


[commons-compress] 01/02: Substituting 'synchronized' with faster and fully thread-safe collections 'ConcurrentLinkedDeque' and iterators.

Posted by bo...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

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

commit e2175822cbc0d13ed1f17fd0be2ac790bf7f93c9
Author: tibordigana <ti...@apache.org>
AuthorDate: Sun May 12 00:50:40 2019 +0200

    Substituting 'synchronized' with faster and fully thread-safe collections 'ConcurrentLinkedDeque' and iterators.
---
 .../archivers/zip/ParallelScatterZipCreator.java   | 36 +++++++++-------------
 1 file changed, 15 insertions(+), 21 deletions(-)

diff --git a/src/main/java/org/apache/commons/compress/archivers/zip/ParallelScatterZipCreator.java b/src/main/java/org/apache/commons/compress/archivers/zip/ParallelScatterZipCreator.java
index c5010c0..dd95882 100644
--- a/src/main/java/org/apache/commons/compress/archivers/zip/ParallelScatterZipCreator.java
+++ b/src/main/java/org/apache/commons/compress/archivers/zip/ParallelScatterZipCreator.java
@@ -24,9 +24,9 @@ import org.apache.commons.compress.parallel.ScatterGatherBackingStoreSupplier;
 
 import java.io.File;
 import java.io.IOException;
-import java.util.ArrayList;
-import java.util.List;
+import java.util.Deque;
 import java.util.concurrent.Callable;
+import java.util.concurrent.ConcurrentLinkedDeque;
 import java.util.concurrent.ExecutionException;
 import java.util.concurrent.ExecutorService;
 import java.util.concurrent.Executors;
@@ -35,7 +35,6 @@ import java.util.concurrent.TimeUnit;
 import java.util.concurrent.atomic.AtomicInteger;
 import java.util.zip.Deflater;
 
-import static java.util.Collections.synchronizedList;
 import static org.apache.commons.compress.archivers.zip.ZipArchiveEntryRequest.createZipArchiveEntryRequest;
 
 /**
@@ -52,10 +51,10 @@ import static org.apache.commons.compress.archivers.zip.ZipArchiveEntryRequest.c
  * @since 1.10
  */
 public class ParallelScatterZipCreator {
-    private final List<ScatterZipOutputStream> streams = synchronizedList(new ArrayList<ScatterZipOutputStream>());
+    private final Deque<ScatterZipOutputStream> streams = new ConcurrentLinkedDeque<>();
     private final ExecutorService es;
     private final ScatterGatherBackingStoreSupplier backingStoreSupplier;
-    private final List<Future<ScatterZipOutputStream>> futures = new ArrayList<>();
+    private final Deque<Future<ScatterZipOutputStream>> futures = new ConcurrentLinkedDeque<>();
 
     private final long startedAt = System.currentTimeMillis();
     private long compressionDoneAt = 0;
@@ -256,16 +255,13 @@ public class ParallelScatterZipCreator {
             // It is important that all threads terminate before we go on, ensure happens-before relationship
             compressionDoneAt = System.currentTimeMillis();
 
-            synchronized (streams) {
-                // write zip entries in the order they were added (kept as futures)
-                for (final Future<ScatterZipOutputStream> future : futures) {
-                    ScatterZipOutputStream scatterStream = future.get();
-                    scatterStream.zipEntryWriter().writeNextZipEntry(targetStream);
-                }
+            for (final Future<ScatterZipOutputStream> future : futures) {
+                ScatterZipOutputStream scatterStream = future.get();
+                scatterStream.zipEntryWriter().writeNextZipEntry(targetStream);
+            }
 
-                for (final ScatterZipOutputStream scatterStream : streams) {
-                    scatterStream.close();
-                }
+            for (final ScatterZipOutputStream scatterStream : streams) {
+                scatterStream.close();
             }
 
             scatterDoneAt = System.currentTimeMillis();
@@ -284,13 +280,11 @@ public class ParallelScatterZipCreator {
     }
 
     private void closeAll() {
-        synchronized (streams) {
-            for (final ScatterZipOutputStream scatterStream : streams) {
-                try {
-                    scatterStream.close();
-                } catch (IOException ex) { //NOSONAR
-                    // no way to properly log this
-                }
+        for (final ScatterZipOutputStream scatterStream : streams) {
+            try {
+                scatterStream.close();
+            } catch (IOException ex) { //NOSONAR
+                // no way to properly log this
             }
         }
     }