From dff95f7af899a4f2add791afbd20c8a1e33c7a36 Mon Sep 17 00:00:00 2001 From: Vinayakumar B Date: Thu, 25 Sep 2014 12:46:47 +0530 Subject: [PATCH] HADOOP-11101. How about inputstream close statement from catch block to finally block in FileContext#copy() ( Contributed by skrho ) --- hadoop-common-project/hadoop-common/CHANGES.txt | 3 +++ .../src/main/java/org/apache/hadoop/fs/FileContext.java | 3 +-- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/hadoop-common-project/hadoop-common/CHANGES.txt b/hadoop-common-project/hadoop-common/CHANGES.txt index a4b33140e1..7bc77dd240 100644 --- a/hadoop-common-project/hadoop-common/CHANGES.txt +++ b/hadoop-common-project/hadoop-common/CHANGES.txt @@ -545,6 +545,9 @@ Release 2.6.0 - UNRELEASED HADOOP-11009. Add Timestamp Preservation to DistCp (Gary Steelman via aw) + HADOOP-11101. How about inputstream close statement from catch block to + finally block in FileContext#copy() ( skrho via vinayakumarb ) + OPTIMIZATIONS HADOOP-10838. Byte array native checksumming. (James Thomas via todd) diff --git a/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/FileContext.java b/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/FileContext.java index c9c8fa8ffd..d878d1788f 100644 --- a/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/FileContext.java +++ b/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/FileContext.java @@ -2021,10 +2021,9 @@ public boolean copy(final Path src, final Path dst, boolean deleteSource, EnumSet.of(CreateFlag.CREATE); out = create(qDst, createFlag); IOUtils.copyBytes(in, out, conf, true); - } catch (IOException e) { + } finally { IOUtils.closeStream(out); IOUtils.closeStream(in); - throw e; } } if (deleteSource) {