[
https://issues.apache.org/jira/browse/HADOOP-7194?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13011916#comment-13011916
]
Devaraj K commented on HADOOP-7194:
-----------------------------------
Thanks Nicholas for reviewing.
Closing the streams in the finally-block using closeStream(..) will suppress
the exception if out.close()/in.close() throws and will not be thrown back to
the caller.
{code:xml}
if(close) {
out.close();
+ out = null;
in.close();
+ in = null;
}
{code}
With the above lines if out.close() throws exception that will be thrown back
to the caller and also other streams will be closed in finally-block using
closeStream(..).
As per the discussions in the issue MAPREDUCE-2243, this way is followed.
> Potential Resource leak in IOUtils.java
> ---------------------------------------
>
> Key: HADOOP-7194
> URL: https://issues.apache.org/jira/browse/HADOOP-7194
> Project: Hadoop Common
> Issue Type: Bug
> Components: io
> Affects Versions: 0.23.0
> Reporter: Devaraj K
> Attachments: HADOOP-7194.patch
>
>
> {code:title=IOUtils.java|borderStyle=solid}
> try {
> copyBytes(in, out, buffSize);
> } finally {
> if(close) {
> out.close();
> in.close();
> }
> }
> {code}
> In the above code if any exception throws from the out.close() statement,
> in.close() statement will not execute and the input stream will not be closed.
--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira