You are viewing a plain text version of this content. The canonical link for it is here.
Posted to common-commits@hadoop.apache.org by cn...@apache.org on 2013/08/22 23:13:51 UTC
svn commit: r1516608 - in
/hadoop/common/trunk/hadoop-common-project/hadoop-common: CHANGES.txt
src/main/java/org/apache/hadoop/fs/Globber.java
Author: cnauroth
Date: Thu Aug 22 21:13:51 2013
New Revision: 1516608
URL: http://svn.apache.org/r1516608
Log:
HADOOP-9887. globStatus does not correctly handle paths starting with a drive spec on Windows. Contributed by Chuan Liu.
Modified:
hadoop/common/trunk/hadoop-common-project/hadoop-common/CHANGES.txt
hadoop/common/trunk/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/Globber.java
Modified: hadoop/common/trunk/hadoop-common-project/hadoop-common/CHANGES.txt
URL: http://svn.apache.org/viewvc/hadoop/common/trunk/hadoop-common-project/hadoop-common/CHANGES.txt?rev=1516608&r1=1516607&r2=1516608&view=diff
==============================================================================
--- hadoop/common/trunk/hadoop-common-project/hadoop-common/CHANGES.txt (original)
+++ hadoop/common/trunk/hadoop-common-project/hadoop-common/CHANGES.txt Thu Aug 22 21:13:51 2013
@@ -420,6 +420,9 @@ Release 2.1.1-beta - UNRELEASED
HADOOP-9880. SASL changes from HADOOP-9421 breaks Secure HA NN. (daryn via
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
INCOMPATIBLE CHANGES
Modified: hadoop/common/trunk/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/Globber.java
URL: http://svn.apache.org/viewvc/hadoop/common/trunk/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/Globber.java?rev=1516608&r1=1516607&r2=1516608&view=diff
==============================================================================
--- hadoop/common/trunk/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/Globber.java (original)
+++ hadoop/common/trunk/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/Globber.java Thu Aug 22 21:13:51 2013
@@ -97,7 +97,7 @@ class Globber {
/**
* Translate an absolute path into a list of path components.
* 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)
throws IOException {
@@ -167,8 +167,8 @@ class Globber {
// Get the absolute path for this flattened pattern. We couldn't do
// this prior to flattening because of patterns like {/,a}, where which
// path you go down influences how the path must be made absolute.
- Path absPattern =
- fixRelativePart(new Path(flatPattern .isEmpty() ? "." : flatPattern ));
+ Path absPattern = fixRelativePart(new Path(
+ flatPattern.isEmpty() ? Path.CUR_DIR : flatPattern));
// Now we break the flattened, absolute pattern into path components.
// For example, /a/*/c would be broken into the list [a, *, c]
List<String> components =
@@ -176,9 +176,19 @@ class Globber {
// Starting out at the root of the filesystem, we try to match
// filesystem entries against pattern components.
ArrayList<FileStatus> candidates = new ArrayList<FileStatus>(1);
- candidates.add(new FileStatus(0, true, 0, 0, 0,
- new Path(scheme, authority, "/")));
-
+ 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,
+ new Path(scheme, authority, Path.SEPARATOR)));
+ }
+
for (String component : components) {
ArrayList<FileStatus> newCandidates =
new ArrayList<FileStatus>(candidates.size());