From c4d4ae62cb94189ad2a37a6c3c47d01abf592cbb Mon Sep 17 00:00:00 2001 From: Inigo Goiri Date: Thu, 17 May 2018 19:26:44 -0700 Subject: [PATCH] HDFS-13586. Fsync fails on directories on Windows. Contributed by Lukas Majercack. (cherry picked from commit 8783613696674aba4ae1739c6e8f48cda0d1c386) --- .../src/main/java/org/apache/hadoop/io/IOUtils.java | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/io/IOUtils.java b/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/io/IOUtils.java index 03c488c9076..547a5b46a20 100644 --- a/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/io/IOUtils.java +++ b/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"); } 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 // we must open r/w for the fsync to have an effect. See // http://blog.httrack.com/blog/2013/11/15/