[ https://issues.apache.org/jira/browse/YARN-2988?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14258038#comment-14258038 ]
Tsuyoshi OZAWA commented on YARN-2988: -------------------------------------- [~ted_yu], thanks for your patch. How about fixing with try-with-resource statement? With the statement, we don't need null check in finally block and it's easier to read. > Graph#save() may leak resource > ------------------------------ > > Key: YARN-2988 > URL: https://issues.apache.org/jira/browse/YARN-2988 > Project: Hadoop YARN > Issue Type: Bug > Reporter: Ted Yu > Assignee: Ted Yu > Priority: Minor > Attachments: YARN-2988-001.patch > > > In > hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/java/org/apache/hadoop/yarn/state/Graph.java > : > {code} > public void save(String filepath) throws IOException { > OutputStreamWriter fout = new OutputStreamWriter( > new FileOutputStream(filepath), Charset.forName("UTF-8")); > fout.write(generateGraphViz()); > fout.close(); > {code} > The close of fout should be enclosed in finally clause. -- This message was sent by Atlassian JIRA (v6.3.4#6332)