diff --git a/hadoop-common-project/hadoop-common/CHANGES.txt b/hadoop-common-project/hadoop-common/CHANGES.txt index c5e0c6892e0..e8a72fe0a17 100644 --- a/hadoop-common-project/hadoop-common/CHANGES.txt +++ b/hadoop-common-project/hadoop-common/CHANGES.txt @@ -827,6 +827,9 @@ Release 0.23.5 - UNRELEASED HADOOP-8811. Compile hadoop native library in FreeBSD (Radim Kolar via bobby) + HADOOP-8962. RawLocalFileSystem.listStatus fails when a child filename + contains a colon (jlowe via bobby) + Release 0.23.4 - UNRELEASED INCOMPATIBLE CHANGES diff --git a/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/RawLocalFileSystem.java b/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/RawLocalFileSystem.java index 9727f14ce24..e4fbe31ce28 100644 --- a/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/RawLocalFileSystem.java +++ b/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/RawLocalFileSystem.java @@ -344,7 +344,7 @@ public class RawLocalFileSystem extends FileSystem { new RawLocalFileStatus(localf, getDefaultBlockSize(f), this) }; } - String[] names = localf.list(); + File[] names = localf.listFiles(); if (names == null) { return null; } @@ -352,7 +352,7 @@ public class RawLocalFileSystem extends FileSystem { int j = 0; for (int i = 0; i < names.length; i++) { try { - results[j] = getFileStatus(new Path(f, names[i])); + results[j] = getFileStatus(new Path(names[i].getAbsolutePath())); j++; } catch (FileNotFoundException e) { // ignore the files not found since the dir list may have have changed diff --git a/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/TestLocalFileSystem.java b/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/TestLocalFileSystem.java index e411314b85e..eb3d33df377 100644 --- a/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/TestLocalFileSystem.java +++ b/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/TestLocalFileSystem.java @@ -249,6 +249,7 @@ public class TestLocalFileSystem { assertEquals(1, fileSchemeCount); } + @Test public void testHasFileDescriptor() throws IOException { Configuration conf = new Configuration(); LocalFileSystem fs = FileSystem.getLocal(conf); @@ -258,4 +259,17 @@ public class TestLocalFileSystem { new RawLocalFileSystem().new LocalFSFileInputStream(path), 1024); 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()); + } }