Repository: commons-compress
Updated Branches:
  refs/heads/master 0437b1845 -> f13364b02


COMPRESS-446 fix resource leak in ParallelScatterZipCreator#writeTo.


Project: http://git-wip-us.apache.org/repos/asf/commons-compress/repo
Commit: http://git-wip-us.apache.org/repos/asf/commons-compress/commit/8faba699
Tree: http://git-wip-us.apache.org/repos/asf/commons-compress/tree/8faba699
Diff: http://git-wip-us.apache.org/repos/asf/commons-compress/diff/8faba699

Branch: refs/heads/master
Commit: 8faba69945721e10b2bea0acda2db53298ffa124
Parents: 0437b18
Author: Stefan Bodewig <[email protected]>
Authored: Thu Mar 29 16:09:33 2018 +0200
Committer: Stefan Bodewig <[email protected]>
Committed: Thu Mar 29 16:09:33 2018 +0200

----------------------------------------------------------------------
 src/changes/changes.xml                                     | 3 +++
 .../compress/archivers/zip/ParallelScatterZipCreator.java   | 9 ++++++++-
 2 files changed, 11 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/commons-compress/blob/8faba699/src/changes/changes.xml
----------------------------------------------------------------------
diff --git a/src/changes/changes.xml b/src/changes/changes.xml
index 8d38663..5f3f9fc 100644
--- a/src/changes/changes.xml
+++ b/src/changes/changes.xml
@@ -48,6 +48,9 @@ The <action> type attribute can be add,update,fix,remove.
         Removed the objenesis dependency from the pom as it is not
         needed at all.
       </action>
+      <action issue="COMPRESS-446" type="fix" date="2018-03-29">
+        Fixed resource leak in ParallelScatterZipCreator#writeTo.
+      </action>
     </release>
     <release version="1.16.1" date="2018-02-10"
              description="Release 1.16.1">

http://git-wip-us.apache.org/repos/asf/commons-compress/blob/8faba699/src/main/java/org/apache/commons/compress/archivers/zip/ParallelScatterZipCreator.java
----------------------------------------------------------------------
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 369a649..b8d4e2c 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
@@ -227,6 +227,10 @@ public class ParallelScatterZipCreator {
      * before calling this method.
      * </p>
      *
+     * <p>Calling this method will shut down the {@link ExecutorService} used 
by this class. If any of the {@link
+     * Callable}s {@link #submit}ted to this instance throws an exception, the 
archive can not be created properly and
+     * this method will throw an exception.</p>
+     *
      * @param targetStream The {@link ZipArchiveOutputStream} to receive the 
contents of the scatter streams
      * @throws IOException          If writing fails
      * @throws InterruptedException If we get interrupted
@@ -236,11 +240,14 @@ public class ParallelScatterZipCreator {
             throws IOException, InterruptedException, ExecutionException {
 
         // Make sure we catch any exceptions from parallel phase
+        try {
         for (final Future<?> future : futures) {
             future.get();
         }
-
+        } finally {
         es.shutdown();
+        }
+
         es.awaitTermination(1000 * 60L, TimeUnit.SECONDS);  // == Infinity. We 
really *must* wait for this to complete
 
         // It is important that all threads terminate before we go on, ensure 
happens-before relationship

Reply via email to