]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
hadoop: Return NULL when the path does not exist.
authorNoah Watkins <noahwatkins@gmail.com>
Mon, 31 Oct 2011 18:15:26 +0000 (11:15 -0700)
committerGreg Farnum <gregory.farnum@dreamhost.com>
Mon, 31 Oct 2011 18:15:26 +0000 (11:15 -0700)
Although unspecified in the declaration header, other file
systems return a single result when the path is a file.

This fixes tracker issue #1661

Signed-off-by: Noah Watkins <noahwatkins@gmail.com>
Signed-off-by: Greg Farnum <gregory.farnum@dreamhost.com>
src/client/hadoop/ceph/CephFileSystem.java

index c69707510d9a509b9d4b3880b1f0015c2999e5ff..a7317b127431690fc6b64db700437e7e94c2f7e2 100644 (file)
@@ -435,9 +435,8 @@ public class CephFileSystem extends FileSystem {
    * Get the FileStatus for each listing in a directory.
    * @param path The directory to get listings from.
    * @return FileStatus[] containing one FileStatus for each directory listing;
-   * null if path is not a directory.
+   *         null if path does not exist.
    * @throws IOException if initialize() hasn't been called.
-   * @throws FileNotFoundException if the input path can't be found.
    */
   public FileStatus[] listStatus(Path path) throws IOException {
     if (!initialized) {
@@ -458,11 +457,12 @@ public class CephFileSystem extends FileSystem {
       ceph.debug("listStatus:exit", ceph.DEBUG);
       return statuses;
     }
-    if (!isFile(path)) {
-      throw new FileNotFoundException();
-    } // if we get here, listPaths returned null
-    // which means that the input wasn't a directory, so throw an Exception if it's not a file
-    return null; // or return null if it's a file
+
+    if (isFile(path)) {
+      return new FileStatus[] { getFileStatus(path) };
+    }
+
+    return null;
   }
 
   @Override