hadoop-common-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rang...@apache.org
Subject svn commit: r697274 - in /hadoop/core/trunk: CHANGES.txt src/core/org/apache/hadoop/fs/FileUtil.java
Date Fri, 19 Sep 2008 22:50:07 GMT
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");



Mime
View raw message