diff --git a/CHANGES.txt b/CHANGES.txt index 0e01dac24be..e88d2b00cc4 100644 --- a/CHANGES.txt +++ b/CHANGES.txt @@ -15,6 +15,10 @@ Trunk (unreleased changes) BUG FIXES + HADOOP-7015. RawLocalFileSystem#listStatus does not deal with a directory + whose entries are changing (e.g. in a multi-thread or multi-process + environment). (Sanjay Radia via eli) + Release 0.22.0 - Unreleased INCOMPATIBLE CHANGES diff --git a/src/java/org/apache/hadoop/fs/RawLocalFileSystem.java b/src/java/org/apache/hadoop/fs/RawLocalFileSystem.java index 413ffd93836..053fd392def 100644 --- a/src/java/org/apache/hadoop/fs/RawLocalFileSystem.java +++ b/src/java/org/apache/hadoop/fs/RawLocalFileSystem.java @@ -28,6 +28,7 @@ import java.io.IOException; import java.io.OutputStream; import java.net.URI; import java.nio.ByteBuffer; +import java.util.Arrays; import java.util.EnumSet; import java.util.StringTokenizer; @@ -319,10 +320,20 @@ public class RawLocalFileSystem extends FileSystem { return null; } results = new FileStatus[names.length]; + int j = 0; for (int i = 0; i < names.length; i++) { - results[i] = getFileStatus(new Path(f, names[i])); + try { + results[j] = getFileStatus(new Path(f, names[i])); + j++; + } catch (FileNotFoundException e) { + // ignore the files not found since the dir list may have have changed + // since the names[] list was generated. + } } - return results; + if (j == names.length) { + return results; + } + return Arrays.copyOf(results, j); } /**