From common-commits-return-77802-archive-asf-public=cust-asf.ponee.io@hadoop.apache.org Tue Jan 23 10:55:41 2018 Return-Path: X-Original-To: archive-asf-public@eu.ponee.io Delivered-To: archive-asf-public@eu.ponee.io Received: from cust-asf.ponee.io (cust-asf.ponee.io [163.172.22.183]) by mx-eu-01.ponee.io (Postfix) with ESMTP id 92790180621 for ; Tue, 23 Jan 2018 10:55:41 +0100 (CET) Received: by cust-asf.ponee.io (Postfix) id 82B9A160C51; Tue, 23 Jan 2018 09:55:41 +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 C7B4E160C4F for ; Tue, 23 Jan 2018 10:55:40 +0100 (CET) Received: (qmail 75248 invoked by uid 500); 23 Jan 2018 09:55:35 -0000 Mailing-List: contact common-commits-help@hadoop.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Delivered-To: mailing list common-commits@hadoop.apache.org Received: (qmail 74993 invoked by uid 99); 23 Jan 2018 09:55:35 -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; Tue, 23 Jan 2018 09:55:35 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id 064C7F4DEB; Tue, 23 Jan 2018 09:55:31 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: sunilg@apache.org To: common-commits@hadoop.apache.org Date: Tue, 23 Jan 2018 09:55:43 -0000 Message-Id: In-Reply-To: <6c5c8a7317bf4efeb21491adc240ac17@git.apache.org> References: <6c5c8a7317bf4efeb21491adc240ac17@git.apache.org> X-Mailer: ASF-Git Admin Mailer Subject: [13/50] [abbrv] hadoop git commit: HADOOP-15114. Add closeStreams(...) to IOUtils (addendum). Contributed by Ajay Kumar. HADOOP-15114. Add closeStreams(...) to IOUtils (addendum). Contributed by Ajay Kumar. Project: http://git-wip-us.apache.org/repos/asf/hadoop/repo Commit: http://git-wip-us.apache.org/repos/asf/hadoop/commit/d689b2d9 Tree: http://git-wip-us.apache.org/repos/asf/hadoop/tree/d689b2d9 Diff: http://git-wip-us.apache.org/repos/asf/hadoop/diff/d689b2d9 Branch: refs/heads/YARN-6592 Commit: d689b2d99c7b4d7e587225638dd8f5af0a690dcc Parents: e5a1ad6 Author: Steve Loughran Authored: Fri Jan 19 14:54:13 2018 +0000 Committer: Steve Loughran Committed: Fri Jan 19 14:54:13 2018 +0000 ---------------------------------------------------------------------- .../java/org/apache/hadoop/io/TestIOUtils.java | 21 +++++++++----------- 1 file changed, 9 insertions(+), 12 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/hadoop/blob/d689b2d9/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/io/TestIOUtils.java ---------------------------------------------------------------------- diff --git a/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/io/TestIOUtils.java b/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/io/TestIOUtils.java index 2e46c62..467e5bc 100644 --- a/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/io/TestIOUtils.java +++ b/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/io/TestIOUtils.java @@ -299,13 +299,14 @@ public class TestIOUtils { } @Test - public void testCloseStreams() { - File tmpFile = new File("deleteMe.txt"); - FileOutputStream fos = null; - BufferedOutputStream bos = null; + public void testCloseStreams() throws IOException { + File tmpFile = null; + FileOutputStream fos; + BufferedOutputStream bos; FileOutputStream nullStream = null; try { + tmpFile = new File(GenericTestUtils.getTestDir(), "testCloseStreams.txt"); fos = new FileOutputStream(tmpFile) { @Override public void close() throws IOException { @@ -315,19 +316,15 @@ public class TestIOUtils { bos = new BufferedOutputStream( new FileOutputStream(tmpFile)) { @Override - public void close() throws IOException { + public void close() { throw new NullPointerException(); } }; - } catch (IOException ioe) { - LOG.warn("Exception in TestIOUtils.testCloseStreams: ", ioe); - } - try { + IOUtils.closeStreams(fos, bos, nullStream); IOUtils.closeStreams(); - } catch (Exception ex) { - LOG.error("Expect IOUtils.closeStreams to close streams quietly.", ex); - throw ex; + } finally { + FileUtils.deleteQuietly(tmpFile); } } --------------------------------------------------------------------- To unsubscribe, e-mail: common-commits-unsubscribe@hadoop.apache.org For additional commands, e-mail: common-commits-help@hadoop.apache.org