浏览代码

HDFS-13586. Fsync fails on directories on Windows. Contributed by Lukas Majercack.

(cherry picked from commit 8783613696674aba4ae1739c6e8f48cda0d1c386)
Inigo Goiri 7 年之前
父节点
当前提交
c4d4ae62cb
共有 1 个文件被更改,包括 7 次插入0 次删除
  1. 7 0
      hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/io/IOUtils.java

+ 7 - 0
hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/io/IOUtils.java

@@ -398,6 +398,13 @@ public class IOUtils {
           "File/Directory " + fileToSync.getAbsolutePath() + " does not exist");
           "File/Directory " + fileToSync.getAbsolutePath() + " does not exist");
     }
     }
     boolean isDir = fileToSync.isDirectory();
     boolean isDir = fileToSync.isDirectory();
+
+    // HDFS-13586, FileChannel.open fails with AccessDeniedException
+    // for any directory, ignore.
+    if (isDir && Shell.WINDOWS) {
+      return;
+    }
+
     // If the file is a directory we have to open read-only, for regular files
     // If the file is a directory we have to open read-only, for regular files
     // we must open r/w for the fsync to have an effect. See
     // we must open r/w for the fsync to have an effect. See
     // http://blog.httrack.com/blog/2013/11/15/
     // http://blog.httrack.com/blog/2013/11/15/