Bläddra i källkod

HADOOP-3535. Fix documentation and name of IOUtils.close to
reflect that it should only be used in cleanup contexts.


git-svn-id: https://svn.apache.org/repos/asf/hadoop/core/trunk@668832 13f79535-47bb-0310-9956-ffa450edef68

Owen O'Malley 17 år sedan
förälder
incheckning
9e113e920d

+ 3 - 0
CHANGES.txt

@@ -304,6 +304,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);
       }
     }
   }