[ 
https://issues.apache.org/jira/browse/HDFS-8951?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14711775#comment-14711775
 ] 

Haohui Mai commented on HDFS-8951:
----------------------------------

Thanks for the work.

{code}
+package org.apache.hadoop.hdfs.util;
+
+import org.slf4j.Logger;
+
+import java.io.IOException;
+
+public class IOUtils {
+
+  /**
+   * 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 cleanup(Logger log, java.io.Closeable... closeables) {
+    for (java.io.Closeable c : closeables) {
+      if (c != null) {
+        try {
+          c.close();
+        } catch(Throwable e) {
+          if (log != null && log.isDebugEnabled()) {
+            log.debug("Exception in closing " + c, e);
+          }
+        }
+      }
+    }
+  }
+
+}
{code}

The change is not required. It's better to change the callers to use 
try-with-resource statement in Java 7.

{code}
-    final DataChecksum checksum = 
BlockMetadataHeader.readDataChecksum(srcMeta);
+    final DataChecksum checksum = BlockMetadataHeader.readDataChecksum(srcMeta,
+        DFSUtil.getIoFileBufferSize(new HdfsConfiguration()));
{code}

Creating a new configuration object will parse the XML configuration every 
single time. The caller needs to use the {{Configuration}} object in the 
{{FSDatasetImpl}} class. Therefore the changes need to be propagated all the 
way along the call chain.

> Move shortcircuit to hdfs-client
> --------------------------------
>
>                 Key: HDFS-8951
>                 URL: https://issues.apache.org/jira/browse/HDFS-8951
>             Project: Hadoop HDFS
>          Issue Type: Sub-task
>          Components: build
>            Reporter: Mingliang Liu
>            Assignee: Mingliang Liu
>         Attachments: HDFS-8951.000.patch, HDFS-8951.001.patch
>
>
> This jira tracks the effort of moving the {{shortcircuit}} package into the 
> hdfs-client module.



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

Reply via email to