浏览代码

HADOOP-3716. Prevent listStatus in KosmosFileSystem from returning
null for valid, empty directories. Contributed by Sriram Rao.


git-svn-id: https://svn.apache.org/repos/asf/hadoop/core/trunk@676069 13f79535-47bb-0310-9956-ffa450edef68

Christopher Douglas 17 年之前
父节点
当前提交
bc0a5e0605

+ 3 - 0
CHANGES.txt

@@ -825,6 +825,9 @@ Release 0.18.0 - Unreleased
     HADOOP-3647. Add debug logs to help track down a very occassional,
     hard-to-reproduce, bug in shuffle/merge on the reducer. (acmurthy) 
 
+    HADOOP-3716. Prevent listStatus in KosmosFileSystem from returning
+    null for valid, empty directories. (Sriram Rao via cdouglas)
+
 Release 0.17.2 - Unreleased
 
   BUG FIXES

+ 0 - 5
src/core/org/apache/hadoop/fs/kfs/KosmosFileSystem.java

@@ -147,11 +147,6 @@ public class KosmosFileSystem extends FileSystem {
 		continue;
 	    numEntries++;
 	}
-	if (numEntries == 0) {
-	    return null;
-        }
-
-        // System.out.println("Calling listStatus on: " + path);
 
 	FileStatus[] pathEntries = new FileStatus[numEntries];
 	int j = 0;

+ 4 - 21
src/test/org/apache/hadoop/fs/kfs/KFSEmulationImpl.java

@@ -51,34 +51,17 @@ public class KFSEmulationImpl implements IFSImpl {
         return localFS.isFile(new Path(path));
     }
 
-    // as part of the emulation, KFS adds ./.. as directory entries
-    // when doing a directory listing.
     public String[] readdir(String path) throws IOException {
         FileStatus[] p = localFS.listStatus(new Path(path));
         String[] entries = null;
 
         if (p == null) {
-            if (isDirectory(path)) {
-                // empty dirs have "." and ".."
-                entries = new String[2];
-                entries[0] = new String(".");
-                entries[1] = new String("..");
-            }
-            return entries;
+            return null;
         }
 
-        if (isDirectory(path)) {
-            // for dirs, add "."/".." as KFS does that
-            entries = new String[p.length + 2];
-            entries[0] = new String(".");
-            entries[1] = new String("..");
-            for (int i = 0; i < p.length; i++)
-                entries[i+2] = p[i].getPath().toString();
-        } else {
-            entries = new String[p.length];
-            for (int i = 0; i < p.length; i++)
-                entries[i] = p[i].getPath().toString();
-        }
+        entries = new String[p.length];
+        for (int i = 0; i < p.length; i++)
+            entries[i] = p[i].getPath().toString();
         return entries;
     }
 

+ 1 - 1
src/test/org/apache/hadoop/fs/kfs/TestKosmosFileSystem.java

@@ -107,7 +107,7 @@ public class TestKosmosFileSystem extends TestCase {
 
         kosmosFileSystem.delete(file2, true);
         p = kosmosFileSystem.listStatus(subDir1);
-        assertEquals(p, null);
+        assertEquals(p.length, 0);
 
         kosmosFileSystem.delete(baseDir, true);
         assertFalse(kosmosFileSystem.exists(baseDir));