HADOOP-8962. RawLocalFileSystem.listStatus fails when a child filename contains a colon (jlowe via bobby)

git-svn-id: https://svn.apache.org/repos/asf/hadoop/common/trunk@1401325 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Robert Joseph Evans 2012-10-23 15:47:26 +00:00
parent 13422461f3
commit b73903f6a7
3 changed files with 19 additions and 2 deletions

View File

@ -1097,6 +1097,9 @@ Release 0.23.5 - UNRELEASED
HADOOP-8811. Compile hadoop native library in FreeBSD (Radim Kolar via HADOOP-8811. Compile hadoop native library in FreeBSD (Radim Kolar via
bobby) bobby)
HADOOP-8962. RawLocalFileSystem.listStatus fails when a child filename
contains a colon (jlowe via bobby)
Release 0.23.4 - UNRELEASED Release 0.23.4 - UNRELEASED
INCOMPATIBLE CHANGES INCOMPATIBLE CHANGES

View File

@ -350,7 +350,7 @@ public class RawLocalFileSystem extends FileSystem {
new RawLocalFileStatus(localf, getDefaultBlockSize(f), this) }; new RawLocalFileStatus(localf, getDefaultBlockSize(f), this) };
} }
String[] names = localf.list(); File[] names = localf.listFiles();
if (names == null) { if (names == null) {
return null; return null;
} }
@ -358,7 +358,7 @@ public class RawLocalFileSystem extends FileSystem {
int j = 0; int j = 0;
for (int i = 0; i < names.length; i++) { for (int i = 0; i < names.length; i++) {
try { try {
results[j] = getFileStatus(new Path(f, names[i])); results[j] = getFileStatus(new Path(names[i].getAbsolutePath()));
j++; j++;
} catch (FileNotFoundException e) { } catch (FileNotFoundException e) {
// ignore the files not found since the dir list may have have changed // ignore the files not found since the dir list may have have changed

View File

@ -249,6 +249,7 @@ public class TestLocalFileSystem {
assertEquals(1, fileSchemeCount); assertEquals(1, fileSchemeCount);
} }
@Test
public void testHasFileDescriptor() throws IOException { public void testHasFileDescriptor() throws IOException {
Configuration conf = new Configuration(); Configuration conf = new Configuration();
LocalFileSystem fs = FileSystem.getLocal(conf); LocalFileSystem fs = FileSystem.getLocal(conf);
@ -258,4 +259,17 @@ public class TestLocalFileSystem {
new RawLocalFileSystem().new LocalFSFileInputStream(path), 1024); new RawLocalFileSystem().new LocalFSFileInputStream(path), 1024);
assertNotNull(bis.getFileDescriptor()); assertNotNull(bis.getFileDescriptor());
} }
@Test
public void testListStatusWithColons() throws IOException {
Configuration conf = new Configuration();
LocalFileSystem fs = FileSystem.getLocal(conf);
File colonFile = new File(TEST_ROOT_DIR, "foo:bar");
colonFile.mkdirs();
colonFile.createNewFile();
FileStatus[] stats = fs.listStatus(new Path(TEST_ROOT_DIR));
assertEquals("Unexpected number of stats", 1, stats.length);
assertEquals("Bad path from stat", colonFile.getAbsolutePath(),
stats[0].getPath().toUri().getPath());
}
} }