HADOOP-7015. RawLocalFileSystem#listStatus does not deal with a directory whose entries are changing (e.g. in a multi-thread or multi-process environment). Contributed by Sanjay Radia

git-svn-id: https://svn.apache.org/repos/asf/hadoop/common/trunk@1036729 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Eli Collins 2010-11-19 03:56:15 +00:00
parent 916e3011db
commit 566597503c
2 changed files with 17 additions and 2 deletions

View File

@ -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

View File

@ -28,6 +28,7 @@
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 FileStatus[] listStatus(Path f) throws IOException {
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);
}
/**