Return-Path: X-Original-To: archive-asf-public-internal@cust-asf2.ponee.io Delivered-To: archive-asf-public-internal@cust-asf2.ponee.io Received: from cust-asf.ponee.io (cust-asf.ponee.io [163.172.22.183]) by cust-asf2.ponee.io (Postfix) with ESMTP id 33E01200BE6 for ; Sat, 19 Nov 2016 23:50:05 +0100 (CET) Received: by cust-asf.ponee.io (Postfix) id 32D93160B17; Sat, 19 Nov 2016 22:50:05 +0000 (UTC) Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by cust-asf.ponee.io (Postfix) with SMTP id 293BE160B2A for ; Sat, 19 Nov 2016 23:50:04 +0100 (CET) Received: (qmail 82935 invoked by uid 500); 19 Nov 2016 22:50:03 -0000 Mailing-List: contact commits-help@zest.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@zest.apache.org Delivered-To: mailing list commits@zest.apache.org Received: (qmail 82430 invoked by uid 99); 19 Nov 2016 22:50:03 -0000 Received: from git1-us-west.apache.org (HELO git1-us-west.apache.org) (140.211.11.23) by apache.org (qpsmtpd/0.29) with ESMTP; Sat, 19 Nov 2016 22:50:03 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id 229B7E1171; Sat, 19 Nov 2016 22:50:03 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: paulmerlin@apache.org To: commits@zest.apache.org Date: Sat, 19 Nov 2016 22:50:20 -0000 Message-Id: <0ea3d518b4ac423ba3fd66d5c625a046@git.apache.org> In-Reply-To: <6cdb4cbde5f24e008ffd912236ef2c97@git.apache.org> References: <6cdb4cbde5f24e008ffd912236ef2c97@git.apache.org> X-Mailer: ASF-Git Admin Mailer Subject: [19/35] zest-java git commit: build: safer cleanup in ExecLogged archived-at: Sat, 19 Nov 2016 22:50:05 -0000 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 Authored: Sat Nov 19 14:23:08 2016 +0100 Committer: Paul Merlin 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 } finally { - [ outStream, errStream ].each { it.close() } + close outStream, errStream } } @@ -80,7 +80,30 @@ class ExecLogged extends AbstractExecTask } finally { - [ outStream, errStream ].each { it.close() } + close outStream, errStream + } + } + + private static void close( Closeable... closeables ) + throws IOException + { + def errors = [ ] as List + 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 } }