hadoop-common-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Brahma Reddy Battula (JIRA)" <j...@apache.org>
Subject [jira] [Commented] (HADOOP-11392) FileUtil.java leaks file descriptor when copybytes success.
Date Fri, 12 Dec 2014 03:12:13 GMT

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

Brahma Reddy Battula commented on HADOOP-11392:
-----------------------------------------------

Hi @Yongjun Zhang
Thanks for taking look into this issue..

Hi [~cnauroth],
Yes, you are correct,Streams will be closed automatically as  *close=true* ..Thanks for pointing
same..One more call is there where  *close=false* ,here I want close streams using Closeable..Please
let me know your thoughts..
{code}
 try {
            IOUtils.copyBytes(in, out, conf, false);
            if (addString!=null)
              out.write(addString.getBytes("UTF-8"));
                
          } finally {
            in.close();
          } 
        }
      }
    } finally {
      out.close();
    }
{code}

want to fix like following..

{code}
 } finally {
           IOUtils.closeStream(in);
          } 
        }
      }
    } finally {
      IOUtils.closeStream(out);
    }
{code}

> FileUtil.java leaks file descriptor when copybytes success.
> -----------------------------------------------------------
>
>                 Key: HADOOP-11392
>                 URL: https://issues.apache.org/jira/browse/HADOOP-11392
>             Project: Hadoop Common
>          Issue Type: Bug
>            Reporter: Brahma Reddy Battula
>            Assignee: Brahma Reddy Battula
>         Attachments: HADOOP-11392.patch
>
>
>  Please check following code for same..
> {code}
> try {
>         in = srcFS.open(src);
>         out = dstFS.create(dst, overwrite);
>         IOUtils.copyBytes(in, out, conf, true);
>       } catch (IOException e) {
>         IOUtils.closeStream(out);
>         IOUtils.closeStream(in);
>         throw e;
>       }
>     }
> {code}



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

Mime
View raw message