polygene-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From paulmer...@apache.org
Subject [19/35] zest-java git commit: build: safer cleanup in ExecLogged
Date Sat, 19 Nov 2016 22:50:20 GMT
build: safer cleanup in ExecLogged


Project: http://git-wip-us.apache.org/repos/asf/zest-java/repo
Commit: http://git-wip-us.apache.org/repos/asf/zest-java/commit/e7fdfb9f
Tree: http://git-wip-us.apache.org/repos/asf/zest-java/tree/e7fdfb9f
Diff: http://git-wip-us.apache.org/repos/asf/zest-java/diff/e7fdfb9f

Branch: refs/heads/develop
Commit: e7fdfb9fa3ca02782ae8137db5a7f700b2b1d11b
Parents: 81ab487
Author: Paul Merlin <paulmerlin@apache.org>
Authored: Sat Nov 19 14:23:08 2016 +0100
Committer: Paul Merlin <paulmerlin@apache.org>
Committed: Sat Nov 19 14:23:08 2016 +0100

----------------------------------------------------------------------
 .../apache/zest/gradle/tasks/ExecLogged.groovy  | 27 ++++++++++++++++++--
 1 file changed, 25 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/zest-java/blob/e7fdfb9f/buildSrc/src/main/groovy/org/apache/zest/gradle/tasks/ExecLogged.groovy
----------------------------------------------------------------------
diff --git a/buildSrc/src/main/groovy/org/apache/zest/gradle/tasks/ExecLogged.groovy b/buildSrc/src/main/groovy/org/apache/zest/gradle/tasks/ExecLogged.groovy
index 3c1a0d5..30075cf 100644
--- a/buildSrc/src/main/groovy/org/apache/zest/gradle/tasks/ExecLogged.groovy
+++ b/buildSrc/src/main/groovy/org/apache/zest/gradle/tasks/ExecLogged.groovy
@@ -57,7 +57,7 @@ class ExecLogged extends AbstractExecTask<ExecLogged>
     }
     finally
     {
-      [ outStream, errStream ].each { it.close() }
+      close outStream, errStream
     }
   }
 
@@ -80,7 +80,30 @@ class ExecLogged extends AbstractExecTask<ExecLogged>
     }
     finally
     {
-      [ outStream, errStream ].each { it.close() }
+      close outStream, errStream
+    }
+  }
+
+  private static void close( Closeable... closeables )
+    throws IOException
+  {
+    def errors = [ ] as List<IOException>
+    for( Closeable closeable : closeables )
+    {
+      try
+      {
+        closeable.close()
+      }
+      catch( IOException ex )
+      {
+        errors.add( ex )
+      }
+    }
+    if( !errors.empty )
+    {
+      def ex = new IOException( 'Failed to close some' )
+      errors.each { ex.addSuppressed it }
+      throw ex
     }
   }
 


Mime
View raw message