From 174b3e8a7482efcf3afe659ca7b903fb7b087d10 Mon Sep 17 00:00:00 2001 From: Thomas White Date: Tue, 8 Sep 2009 12:18:06 +0000 Subject: [PATCH] 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 --- CHANGES.txt | 3 +++ .../org/apache/hadoop/fs/s3native/NativeS3FileSystem.java | 1 + .../fs/s3native/NativeS3FileSystemContractBaseTest.java | 5 ++++- 3 files changed, 8 insertions(+), 1 deletion(-) diff --git a/CHANGES.txt b/CHANGES.txt index 75917b6261d..e9eb093a3be 100644 --- a/CHANGES.txt +++ b/CHANGES.txt @@ -987,6 +987,9 @@ Trunk (unreleased changes) HADOOP-6243. Fix a NullPointerException in processing deprecated keys. (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 INCOMPATIBLE CHANGES diff --git a/src/java/org/apache/hadoop/fs/s3native/NativeS3FileSystem.java b/src/java/org/apache/hadoop/fs/s3native/NativeS3FileSystem.java index 6ea0fa41bf0..ea5a23b3b25 100644 --- a/src/java/org/apache/hadoop/fs/s3native/NativeS3FileSystem.java +++ b/src/java/org/apache/hadoop/fs/s3native/NativeS3FileSystem.java @@ -455,6 +455,7 @@ public class NativeS3FileSystem extends FileSystem { } while (priorLastKey != null); if (status.isEmpty() && + key.length() > 0 && store.retrieveMetadata(key + FOLDER_SUFFIX) == null) { throw new FileNotFoundException("File " + f + " does not exist."); } diff --git a/src/test/core/org/apache/hadoop/fs/s3native/NativeS3FileSystemContractBaseTest.java b/src/test/core/org/apache/hadoop/fs/s3native/NativeS3FileSystemContractBaseTest.java index bd94093ee37..337eeaba5bb 100644 --- a/src/test/core/org/apache/hadoop/fs/s3native/NativeS3FileSystemContractBaseTest.java +++ b/src/test/core/org/apache/hadoop/fs/s3native/NativeS3FileSystemContractBaseTest.java @@ -48,10 +48,13 @@ public abstract class NativeS3FileSystemContractBaseTest } public void testListStatusForRoot() throws Exception { + FileStatus[] paths = fs.listStatus(path("/")); + assertEquals(0, paths.length); + Path testDir = path("/test"); assertTrue(fs.mkdirs(testDir)); - FileStatus[] paths = fs.listStatus(path("/")); + paths = fs.listStatus(path("/")); assertEquals(1, paths.length); assertEquals(path("/test"), paths[0].getPath()); }