[
https://issues.apache.org/jira/browse/YARN-2937?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14257404#comment-14257404
]
Varun Saxena commented on YARN-2937:
------------------------------------
[~zjshen], I think it can be changed as under. Because, as you said PrintWriter
doesnt throw exceptions. So, we should check for error after call to
{{PrintWriter#write}}. Let me know if you would want me to throw IOException
from finally block too. After that I will upload a new patch.
{code}
PrintWriter pw = null;
try {
File file = new File(path + "/" + param);
Writer w = new OutputStreamWriter(new FileOutputStream(file), "UTF-8");
pw = new PrintWriter(w);
pw.write(value);
if(pw.checkError()) {
throw new IOException();
}
} catch (IOException e) {
throw new IOException("Unable to set " + param + "=" + value +
" for cgroup at: " + path, e);
} finally {
if (pw != null) {
pw.close();
if(pw.checkError()) {
LOG.warn("Error while closing cgroup file " + path);
}
}
}
{code}
> Fix new findbugs warnings in hadoop-yarn-nodemanager
> ----------------------------------------------------
>
> Key: YARN-2937
> URL: https://issues.apache.org/jira/browse/YARN-2937
> Project: Hadoop YARN
> Issue Type: Improvement
> Reporter: Varun Saxena
> Assignee: Varun Saxena
> Fix For: 2.7.0
>
> Attachments: YARN-2937.001.patch, YARN-2937.002.patch,
> YARN-2937.003.patch, YARN-2937.004.patch, YARN-2937.005.patch
>
>
--
This message was sent by Atlassian JIRA
(v6.3.4#6332)