[ 
https://issues.apache.org/jira/browse/YARN-2937?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14257427#comment-14257427
 ] 

Varun Saxena commented on YARN-2937:
------------------------------------

bq. IMHO, we can simply throw it at finally block. It's not necessary to throw 
IOException and then wrap it in another IOException.
[~zjshen], thats true but the issue with that is what should be the exception 
message. If there is exception in write() we should probably send back an 
exception to the caller  stating unable to set cgroup. If closing of 
printwriter fails, it may not mean that cgroup hasnt been set.
{{throw new IOException("Unable to set " + param + "=" + value +
          " for cgroup at: " + path, e);}}

I feel code can be changed as under then. Pls note that we did not throw an 
exception on close of FileWriter earlier.
} finally {
      if (pw != null) {
        boolean hasError = pw.checkError();
       
        pw.close();
        if(hasError) {
          throw new IOException("Unable to set " + param + "=" + value +
             " for cgroup at: " + path);
        }
        if(pw.checkError()) {
          throw new IOException("Error while closing cgroup file " + path);
        }
      }
    }

> 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)

Reply via email to