diff --git a/hadoop-common-project/hadoop-common/CHANGES.txt b/hadoop-common-project/hadoop-common/CHANGES.txt index 1532af32fa9..7040048cd02 100644 --- a/hadoop-common-project/hadoop-common/CHANGES.txt +++ b/hadoop-common-project/hadoop-common/CHANGES.txt @@ -1015,6 +1015,9 @@ Release 2.8.0 - UNRELEASED HADOOP-12731. Remove useless boxing/unboxing code. (Kousuke Saruta via aajisaka) + HADOOP-12718. Incorrect error message by fs -put local dir without + permission. (John Zhuge via Yongjun Zhang) + Release 2.7.3 - UNRELEASED INCOMPATIBLE CHANGES diff --git a/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/RawLocalFileSystem.java b/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/RawLocalFileSystem.java index a6a966527bf..318bbb063ff 100644 --- a/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/RawLocalFileSystem.java +++ b/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/RawLocalFileSystem.java @@ -33,6 +33,7 @@ import java.io.OutputStream; import java.io.FileDescriptor; import java.net.URI; import java.nio.ByteBuffer; +import java.nio.file.AccessDeniedException; import java.nio.file.Files; import java.nio.file.NoSuchFileException; import java.nio.file.attribute.BasicFileAttributes; @@ -450,6 +451,10 @@ public class RawLocalFileSystem extends FileSystem { if (localf.isDirectory()) { String[] names = localf.list(); if (names == null) { + if (!localf.canRead()) { + throw new AccessDeniedException("cannot open directory " + f + + ": Permission denied"); + } return null; } results = new FileStatus[names.length];