hadoop: fix contract for listStatus
PATCH 1/1 hadoop: fix contract for listStatus
Return NULL when the path does not exist. Although unspecified in the declaration header, other file systems return a single result when the path is a file.
This fixes tracker issue #1661
--- src/client/hadoop/ceph/CephFileSystem.java | 14 +++++++------- 1 files changed, 7 insertions(+), 7 deletions(-)
src/client/hadoop/ceph/CephFileSystem.java +7 -7
@@ -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
Signature · 1 line
1.7.5.4
Just pushed this to master in commit:f9b7ecdb5bba1439dc4c13005a6213ddb6ecfcc5, with a minor change to the patch description. :)
Thanks!
Quoted 43 lines · Noah Watkins
Return NULL when the path does not exist. 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 <[email protected]>---
src/client/hadoop/ceph/CephFileSystem.java | 14 +++++++-------1 files changed, 7 insertions(+), 7 deletions(-)src/client/hadoop/ceph/CephFileSystem.java +7
-7@@ -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; }
Quoted 8 lines
@Override
--
1.7.5.4
--
To unsubscribe from this list: send the line "unsubscribe ceph-devel" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
--
To unsubscribe from this list: send the line "unsubscribe ceph-devel" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html