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.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,11 +320,21 @@ 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.
}
}
if (j == names.length) {
return results;
}
return Arrays.copyOf(results, j);
}
/**
* Creates the specified directory hierarchy. Does not