HADOOP-6009. S3N listStatus incorrectly returns null instead of empty array when called on empty root. Contributed by Ian Nowland.

git-svn-id: https://svn.apache.org/repos/asf/hadoop/common/trunk@812479 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Thomas White 2009-09-08 12:18:06 +00:00
parent 4a4dd27571
commit 174b3e8a74
3 changed files with 8 additions and 1 deletions

View File

@ -987,6 +987,9 @@ Trunk (unreleased changes)
HADOOP-6243. Fix a NullPointerException in processing deprecated keys. HADOOP-6243. Fix a NullPointerException in processing deprecated keys.
(Sreekanth Ramakrishnan via yhemanth) (Sreekanth Ramakrishnan via yhemanth)
HADOOP-6009. S3N listStatus incorrectly returns null instead of empty
array when called on empty root. (Ian Nowland via tomwhite)
Release 0.20.1 - Unreleased Release 0.20.1 - Unreleased
INCOMPATIBLE CHANGES INCOMPATIBLE CHANGES

View File

@ -455,6 +455,7 @@ public class NativeS3FileSystem extends FileSystem {
} while (priorLastKey != null); } while (priorLastKey != null);
if (status.isEmpty() && if (status.isEmpty() &&
key.length() > 0 &&
store.retrieveMetadata(key + FOLDER_SUFFIX) == null) { store.retrieveMetadata(key + FOLDER_SUFFIX) == null) {
throw new FileNotFoundException("File " + f + " does not exist."); throw new FileNotFoundException("File " + f + " does not exist.");
} }

View File

@ -48,10 +48,13 @@ public abstract class NativeS3FileSystemContractBaseTest
} }
public void testListStatusForRoot() throws Exception { public void testListStatusForRoot() throws Exception {
FileStatus[] paths = fs.listStatus(path("/"));
assertEquals(0, paths.length);
Path testDir = path("/test"); Path testDir = path("/test");
assertTrue(fs.mkdirs(testDir)); assertTrue(fs.mkdirs(testDir));
FileStatus[] paths = fs.listStatus(path("/")); paths = fs.listStatus(path("/"));
assertEquals(1, paths.length); assertEquals(1, paths.length);
assertEquals(path("/test"), paths[0].getPath()); assertEquals(path("/test"), paths[0].getPath());
} }