HADOOP-9887. globStatus does not correctly handle paths starting with a drive spec on Windows. Contributed by Chuan Liu.
git-svn-id: https://svn.apache.org/repos/asf/hadoop/common/trunk@1516608 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
d2c70e3e94
commit
d1dfa5f923
|
@ -420,6 +420,9 @@ Release 2.1.1-beta - UNRELEASED
|
||||||
HADOOP-9880. SASL changes from HADOOP-9421 breaks Secure HA NN. (daryn via
|
HADOOP-9880. SASL changes from HADOOP-9421 breaks Secure HA NN. (daryn via
|
||||||
jing9)
|
jing9)
|
||||||
|
|
||||||
|
HADOOP-9887. globStatus does not correctly handle paths starting with a drive
|
||||||
|
spec on Windows. (Chuan Liu via cnauroth)
|
||||||
|
|
||||||
Release 2.1.0-beta - 2013-08-22
|
Release 2.1.0-beta - 2013-08-22
|
||||||
|
|
||||||
INCOMPATIBLE CHANGES
|
INCOMPATIBLE CHANGES
|
||||||
|
|
|
@ -97,7 +97,7 @@ class Globber {
|
||||||
/**
|
/**
|
||||||
* Translate an absolute path into a list of path components.
|
* Translate an absolute path into a list of path components.
|
||||||
* We merge double slashes into a single slash here.
|
* We merge double slashes into a single slash here.
|
||||||
* The first path component (i.e. root) does not get an entry in the list.
|
* POSIX root path, i.e. '/', does not get an entry in the list.
|
||||||
*/
|
*/
|
||||||
private static List<String> getPathComponents(String path)
|
private static List<String> getPathComponents(String path)
|
||||||
throws IOException {
|
throws IOException {
|
||||||
|
@ -167,8 +167,8 @@ class Globber {
|
||||||
// Get the absolute path for this flattened pattern. We couldn't do
|
// Get the absolute path for this flattened pattern. We couldn't do
|
||||||
// this prior to flattening because of patterns like {/,a}, where which
|
// this prior to flattening because of patterns like {/,a}, where which
|
||||||
// path you go down influences how the path must be made absolute.
|
// path you go down influences how the path must be made absolute.
|
||||||
Path absPattern =
|
Path absPattern = fixRelativePart(new Path(
|
||||||
fixRelativePart(new Path(flatPattern .isEmpty() ? "." : flatPattern ));
|
flatPattern.isEmpty() ? Path.CUR_DIR : flatPattern));
|
||||||
// Now we break the flattened, absolute pattern into path components.
|
// Now we break the flattened, absolute pattern into path components.
|
||||||
// For example, /a/*/c would be broken into the list [a, *, c]
|
// For example, /a/*/c would be broken into the list [a, *, c]
|
||||||
List<String> components =
|
List<String> components =
|
||||||
|
@ -176,8 +176,18 @@ class Globber {
|
||||||
// Starting out at the root of the filesystem, we try to match
|
// Starting out at the root of the filesystem, we try to match
|
||||||
// filesystem entries against pattern components.
|
// filesystem entries against pattern components.
|
||||||
ArrayList<FileStatus> candidates = new ArrayList<FileStatus>(1);
|
ArrayList<FileStatus> candidates = new ArrayList<FileStatus>(1);
|
||||||
|
if (Path.WINDOWS && !components.isEmpty()
|
||||||
|
&& Path.isWindowsAbsolutePath(absPattern.toUri().getPath(), true)) {
|
||||||
|
// On Windows the path could begin with a drive letter, e.g. /E:/foo.
|
||||||
|
// We will skip matching the drive letter and start from listing the
|
||||||
|
// root of the filesystem on that drive.
|
||||||
|
String driveLetter = components.remove(0);
|
||||||
|
candidates.add(new FileStatus(0, true, 0, 0, 0, new Path(scheme,
|
||||||
|
authority, Path.SEPARATOR + driveLetter + Path.SEPARATOR)));
|
||||||
|
} else {
|
||||||
candidates.add(new FileStatus(0, true, 0, 0, 0,
|
candidates.add(new FileStatus(0, true, 0, 0, 0,
|
||||||
new Path(scheme, authority, "/")));
|
new Path(scheme, authority, Path.SEPARATOR)));
|
||||||
|
}
|
||||||
|
|
||||||
for (String component : components) {
|
for (String component : components) {
|
||||||
ArrayList<FileStatus> newCandidates =
|
ArrayList<FileStatus> newCandidates =
|
||||||
|
|
Loading…
Reference in New Issue