HADOOP-8709. globStatus changed behavior from 0.20/1.x (Jason Lowe via bobby)
git-svn-id: https://svn.apache.org/repos/asf/hadoop/common/trunk@1376653 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
9ef3b2eb60
commit
4f8e1f779b
|
@ -966,6 +966,9 @@ Release 0.23.3 - UNRELEASED
|
||||||
|
|
||||||
HADOOP-8225. DistCp fails when invoked by Oozie (daryn via bobby)
|
HADOOP-8225. DistCp fails when invoked by Oozie (daryn via bobby)
|
||||||
|
|
||||||
|
HADOOP-8709. globStatus changed behavior from 0.20/1.x (Jason Lowe via
|
||||||
|
bobby)
|
||||||
|
|
||||||
Release 0.23.2 - UNRELEASED
|
Release 0.23.2 - UNRELEASED
|
||||||
|
|
||||||
INCOMPATIBLE CHANGES
|
INCOMPATIBLE CHANGES
|
||||||
|
|
|
@ -2014,7 +2014,11 @@ public final class FileContext {
|
||||||
new GlobFilter(components[components.length - 1], filter);
|
new GlobFilter(components[components.length - 1], filter);
|
||||||
if (fp.hasPattern()) { // last component has a pattern
|
if (fp.hasPattern()) { // last component has a pattern
|
||||||
// list parent directories and then glob the results
|
// list parent directories and then glob the results
|
||||||
results = listStatus(parentPaths, fp);
|
try {
|
||||||
|
results = listStatus(parentPaths, fp);
|
||||||
|
} catch (FileNotFoundException e) {
|
||||||
|
results = null;
|
||||||
|
}
|
||||||
hasGlob[0] = true;
|
hasGlob[0] = true;
|
||||||
} else { // last component does not have a pattern
|
} else { // last component does not have a pattern
|
||||||
// get all the path names
|
// get all the path names
|
||||||
|
@ -2065,7 +2069,11 @@ public final class FileContext {
|
||||||
}
|
}
|
||||||
GlobFilter fp = new GlobFilter(filePattern[level]);
|
GlobFilter fp = new GlobFilter(filePattern[level]);
|
||||||
if (fp.hasPattern()) {
|
if (fp.hasPattern()) {
|
||||||
parents = FileUtil.stat2Paths(listStatus(parents, fp));
|
try {
|
||||||
|
parents = FileUtil.stat2Paths(listStatus(parents, fp));
|
||||||
|
} catch (FileNotFoundException e) {
|
||||||
|
parents = null;
|
||||||
|
}
|
||||||
hasGlob[0] = true;
|
hasGlob[0] = true;
|
||||||
} else {
|
} else {
|
||||||
for (int i = 0; i < parents.length; i++) {
|
for (int i = 0; i < parents.length; i++) {
|
||||||
|
|
|
@ -1619,7 +1619,11 @@ public abstract class FileSystem extends Configured implements Closeable {
|
||||||
GlobFilter fp = new GlobFilter(components[components.length - 1], filter);
|
GlobFilter fp = new GlobFilter(components[components.length - 1], filter);
|
||||||
if (fp.hasPattern()) { // last component has a pattern
|
if (fp.hasPattern()) { // last component has a pattern
|
||||||
// list parent directories and then glob the results
|
// list parent directories and then glob the results
|
||||||
results = listStatus(parentPaths, fp);
|
try {
|
||||||
|
results = listStatus(parentPaths, fp);
|
||||||
|
} catch (FileNotFoundException e) {
|
||||||
|
results = null;
|
||||||
|
}
|
||||||
hasGlob[0] = true;
|
hasGlob[0] = true;
|
||||||
} else { // last component does not have a pattern
|
} else { // last component does not have a pattern
|
||||||
// remove the quoting of metachars in a non-regexp expansion
|
// remove the quoting of metachars in a non-regexp expansion
|
||||||
|
@ -1668,7 +1672,11 @@ public abstract class FileSystem extends Configured implements Closeable {
|
||||||
}
|
}
|
||||||
GlobFilter fp = new GlobFilter(filePattern[level]);
|
GlobFilter fp = new GlobFilter(filePattern[level]);
|
||||||
if (fp.hasPattern()) {
|
if (fp.hasPattern()) {
|
||||||
parents = FileUtil.stat2Paths(listStatus(parents, fp));
|
try {
|
||||||
|
parents = FileUtil.stat2Paths(listStatus(parents, fp));
|
||||||
|
} catch (FileNotFoundException e) {
|
||||||
|
parents = null;
|
||||||
|
}
|
||||||
hasGlob[0] = true;
|
hasGlob[0] = true;
|
||||||
} else { // the component does not have a pattern
|
} else { // the component does not have a pattern
|
||||||
// remove the quoting of metachars in a non-regexp expansion
|
// remove the quoting of metachars in a non-regexp expansion
|
||||||
|
|
|
@ -364,15 +364,17 @@ public abstract class FSMainOperationsBaseTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testGlobStatusThrowsExceptionForNonExistentFile() throws Exception {
|
public void testGlobStatusNonExistentFile() throws Exception {
|
||||||
try {
|
FileStatus[] paths = fSys.globStatus(
|
||||||
// This should throw a FileNotFoundException
|
getTestRootPath(fSys, "test/hadoopfsdf"));
|
||||||
fSys.globStatus(
|
Assert.assertNull(paths);
|
||||||
getTestRootPath(fSys, "test/hadoopfsdf/?"));
|
|
||||||
Assert.fail("Should throw FileNotFoundException");
|
paths = fSys.globStatus(
|
||||||
} catch (FileNotFoundException fnfe) {
|
getTestRootPath(fSys, "test/hadoopfsdf/?"));
|
||||||
// expected
|
Assert.assertEquals(0, paths.length);
|
||||||
}
|
paths = fSys.globStatus(
|
||||||
|
getTestRootPath(fSys, "test/hadoopfsdf/xyz*/?"));
|
||||||
|
Assert.assertEquals(0, paths.length);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
|
|
@ -360,15 +360,17 @@ public abstract class FileContextMainOperationsBaseTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testGlobStatusThrowsExceptionForNonExistentFile() throws Exception {
|
public void testGlobStatusNonExistentFile() throws Exception {
|
||||||
try {
|
FileStatus[] paths = fc.util().globStatus(
|
||||||
// This should throw a FileNotFoundException
|
getTestRootPath(fc, "test/hadoopfsdf"));
|
||||||
fc.util().globStatus(
|
Assert.assertNull(paths);
|
||||||
getTestRootPath(fc, "test/hadoopfsdf/?"));
|
|
||||||
Assert.fail("Should throw FileNotFoundException");
|
paths = fc.util().globStatus(
|
||||||
} catch (FileNotFoundException fnfe) {
|
getTestRootPath(fc, "test/hadoopfsdf/?"));
|
||||||
// expected
|
Assert.assertEquals(0, paths.length);
|
||||||
}
|
paths = fc.util().globStatus(
|
||||||
|
getTestRootPath(fc, "test/hadoopfsdf/xyz*/?"));
|
||||||
|
Assert.assertEquals(0, paths.length);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
|
Loading…
Reference in New Issue