diff --git a/hadoop-yarn-project/CHANGES.txt b/hadoop-yarn-project/CHANGES.txt index f0d4af60a0a..5dfb2789fdc 100644 --- a/hadoop-yarn-project/CHANGES.txt +++ b/hadoop-yarn-project/CHANGES.txt @@ -284,6 +284,8 @@ Release 2.7.0 - UNRELEASED YARN-2946. Fixed potential deadlock in RMStateStore. (Rohith Sharmaks via jianhe) + YARN-2988. Graph#save() may leak file descriptors. (Ted Yu via ozawa) + Release 2.6.0 - 2014-11-18 INCOMPATIBLE CHANGES diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/java/org/apache/hadoop/yarn/state/Graph.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/java/org/apache/hadoop/yarn/state/Graph.java index a090194ba1a..390deb21bf5 100644 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/java/org/apache/hadoop/yarn/state/Graph.java +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/java/org/apache/hadoop/yarn/state/Graph.java @@ -188,10 +188,10 @@ public class Graph { } public void save(String filepath) throws IOException { - OutputStreamWriter fout = new OutputStreamWriter( - new FileOutputStream(filepath), Charset.forName("UTF-8")); - fout.write(generateGraphViz()); - fout.close(); + try (OutputStreamWriter fout = new OutputStreamWriter( + new FileOutputStream(filepath), Charset.forName("UTF-8"));) { + fout.write(generateGraphViz()); + } } public static List combineEdges(List edges) {