You are viewing a plain text version of this content. The canonical link for it is here.
Posted to common-commits@hadoop.apache.org by ra...@apache.org on 2008/09/20 00:50:07 UTC
svn commit: r697274 - in /hadoop/core/trunk: CHANGES.txt
src/core/org/apache/hadoop/fs/FileUtil.java
Author: rangadi
Date: Fri Sep 19 15:50:07 2008
New Revision: 697274
URL: http://svn.apache.org/viewvc?rev=697274&view=rev
Log:
HADOOP-3592. Fix a couple of possible file leaks in FileUtil (Bill de hOra via rangadi)
Modified:
hadoop/core/trunk/CHANGES.txt
hadoop/core/trunk/src/core/org/apache/hadoop/fs/FileUtil.java
Modified: hadoop/core/trunk/CHANGES.txt
URL: http://svn.apache.org/viewvc/hadoop/core/trunk/CHANGES.txt?rev=697274&r1=697273&r2=697274&view=diff
==============================================================================
--- hadoop/core/trunk/CHANGES.txt (original)
+++ hadoop/core/trunk/CHANGES.txt Fri Sep 19 15:50:07 2008
@@ -687,6 +687,9 @@
HADOOP-4077. Setting access and modification time for a file
requires write permissions on the file. (dhruba)
+ HADOOP-3592. Fix a couple of possible file leaks in FileUtil
+ (Bill de hOra via rangadi)
+
Release 0.18.1 - 2008-09-17
IMPROVEMENTS
Modified: hadoop/core/trunk/src/core/org/apache/hadoop/fs/FileUtil.java
URL: http://svn.apache.org/viewvc/hadoop/core/trunk/src/core/org/apache/hadoop/fs/FileUtil.java?rev=697274&r1=697273&r2=697274&view=diff
==============================================================================
--- hadoop/core/trunk/src/core/org/apache/hadoop/fs/FileUtil.java (original)
+++ hadoop/core/trunk/src/core/org/apache/hadoop/fs/FileUtil.java Fri Sep 19 15:50:07 2008
@@ -201,9 +201,17 @@
deleteSource, overwrite, conf);
}
} else if (srcFS.isFile(src)) {
- InputStream in = srcFS.open(src);
- OutputStream out = dstFS.create(dst, overwrite);
- IOUtils.copyBytes(in, out, conf, true);
+ InputStream in=null;
+ OutputStream out = null;
+ 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;
+ }
} else {
throw new IOException(src.toString() + ": No such file or directory");
}
@@ -271,8 +279,17 @@
deleteSource, conf);
}
} else if (src.isFile()) {
- InputStream in = new FileInputStream(src);
- IOUtils.copyBytes(in, dstFS.create(dst), conf);
+ InputStream in = null;
+ OutputStream out =null;
+ try {
+ in = new FileInputStream(src);
+ out = dstFS.create(dst);
+ IOUtils.copyBytes(in, out, conf);
+ } catch (IOException e) {
+ IOUtils.closeStream( out );
+ IOUtils.closeStream( in );
+ throw e;
+ }
} else {
throw new IOException(src.toString() +
": No such file or directory");