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:
parent
916e3011db
commit
566597503c
|
@ -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
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Loading…
Reference in New Issue