diff --git a/hadoop-common-project/hadoop-common/CHANGES.txt b/hadoop-common-project/hadoop-common/CHANGES.txt index 40aab85646..0019b3a629 100644 --- a/hadoop-common-project/hadoop-common/CHANGES.txt +++ b/hadoop-common-project/hadoop-common/CHANGES.txt @@ -552,6 +552,10 @@ Release 2.7.0 - UNRELEASED HADOOP-11378. Fix new findbugs warnings in hadoop-kms. (Li Lu via wheat9) + HADOOP-11349. RawLocalFileSystem leaks file descriptor while creating a + file if creat succeeds but chmod fails. (Varun Saxena via Colin P. McCabe) + + Release 2.6.0 - 2014-11-18 INCOMPATIBLE CHANGES diff --git a/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/RawLocalFileSystem.java b/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/RawLocalFileSystem.java index b6b6f59054..858789e5f3 100644 --- a/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/RawLocalFileSystem.java +++ b/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/RawLocalFileSystem.java @@ -41,6 +41,7 @@ import org.apache.hadoop.classification.InterfaceAudience; import org.apache.hadoop.classification.InterfaceStability; import org.apache.hadoop.conf.Configuration; import org.apache.hadoop.fs.permission.FsPermission; +import org.apache.hadoop.io.IOUtils; import org.apache.hadoop.io.nativeio.NativeIO; import org.apache.hadoop.util.Progressable; import org.apache.hadoop.util.Shell; @@ -295,8 +296,16 @@ public class RawLocalFileSystem extends FileSystem { FSDataOutputStream out = create(f, overwrite, bufferSize, replication, blockSize, progress); - setPermission(f, permission); - return out; + boolean success = false; + try { + setPermission(f, permission); + success = true; + return out; + } finally { + if (!success) { + IOUtils.cleanup(LOG, out); + } + } } @Override @@ -306,8 +315,16 @@ public class RawLocalFileSystem extends FileSystem { Progressable progress) throws IOException { FSDataOutputStream out = create(f, overwrite, false, bufferSize, replication, blockSize, progress); - setPermission(f, permission); - return out; + boolean success = false; + try { + setPermission(f, permission); + success = true; + return out; + } finally { + if (!success) { + IOUtils.cleanup(LOG, out); + } + } } @Override