瀏覽代碼

HADOOP-3535. Merge -r 668831:668832 from trunk to branch 0.18.

git-svn-id: https://svn.apache.org/repos/asf/hadoop/core/branches/branch-0.18@668833 13f79535-47bb-0310-9956-ffa450edef68
Owen O'Malley 17 年之前
父節點
當前提交
c0ba6de2dd
共有 3 個文件被更改,包括 11 次插入6 次删除
  1. 3 0
      CHANGES.txt
  2. 7 5
      src/core/org/apache/hadoop/io/IOUtils.java
  3. 1 1
      src/hdfs/org/apache/hadoop/dfs/FSNamesystem.java

+ 3 - 0
CHANGES.txt

@@ -293,6 +293,9 @@ Release 0.18.0 - Unreleased
     HADOOP-2762. Add forrest documentation for controls of memory limits on 
     hadoop daemons and Map-Reduce tasks. (Amareshwari Sriramadasu via ddas)
 
+    HADOOP-3535. Fix documentation and name of IOUtils.close to
+    reflect that it should only be used in cleanup contexts. (omalley)
+
   OPTIMIZATIONS
 
     HADOOP-3274. The default constructor of BytesWritable creates empty 

+ 7 - 5
src/core/org/apache/hadoop/io/IOUtils.java

@@ -123,11 +123,12 @@ public class IOUtils {
   }
   
   /**
-   * Close the Closeable objects.
-   * Log {@link IOException} if there is any. 
+   * Close the Closeable objects and <b>ignore</b> any {@link IOException} or 
+   * null pointers. Must only be used for cleanup in exception handlers.
+   * @param log the log to record problems to at debug level. Can be null.
    * @param closeables the objects to close
    */
-  public static void close(Log log, java.io.Closeable... closeables) {
+  public static void cleanup(Log log, java.io.Closeable... closeables) {
     for(java.io.Closeable c : closeables) {
       if (c != null) {
         try {
@@ -142,11 +143,12 @@ public class IOUtils {
   }
 
   /**
-   * Closes the stream ignoring {@link IOException} 
+   * Closes the stream ignoring {@link IOException}.
+   * Must only be called in cleaning up from exception handlers.
    * @param stream the Stream to close
    */
   public static void closeStream( java.io.Closeable stream ) {
-    close(null, stream);
+    cleanup(null, stream);
   }
   
   /**

+ 1 - 1
src/hdfs/org/apache/hadoop/dfs/FSNamesystem.java

@@ -463,7 +463,7 @@ class FSNamesystem implements FSConstants, FSNamesystemMBean {
         }
       } catch (InterruptedException ie) {
       } finally {
-        IOUtils.close(LOG, dir);
+        IOUtils.cleanup(LOG, dir);
       }
     }
   }