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

Colin Patrick McCabe commented on HADOOP-11056:
-----------------------------------------------

{code}
+    if (stream != null) {
+      stream.close();
+      stream = null;
+    }
{code}

If an exception happens, stream never gets set to null.  Anyway, please use 
{{IOUtils.cleanup}} instead of this.

{code}
+      if (stream != null) {
+        try {
+          close();
+        } catch (IOException e1) {
+          throw new RuntimeException(e1);
+        }
+      }
{code}

You don't need to check if stream is null, since close checks that for you.

Also don't make your close method throw IOException, and you won't need this 
extra catch block.

> OsSecureRandom.setConf() might leak resource
> --------------------------------------------
>
>                 Key: HADOOP-11056
>                 URL: https://issues.apache.org/jira/browse/HADOOP-11056
>             Project: Hadoop Common
>          Issue Type: Bug
>          Components: security
>    Affects Versions: 2.5.0
>            Reporter: Yongjun Zhang
>            Assignee: Yongjun Zhang
>         Attachments: HADOOP-11056.001.patch
>
>
> OsSecureRandom.setConf() might leak resource, the stream is not closed when:
> 1. if setConf() is called a second time
> 2. if {{fillReservoir(0);}} throw exception.
>  



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

Reply via email to