From afad13f8d9ee75c38c1c836b3b5fd471e629d94e Mon Sep 17 00:00:00 2001 From: Mingliang Liu Date: Wed, 30 Nov 2016 13:01:02 -0800 Subject: [PATCH] HADOOP-13830. Intermittent failure of ITestS3NContractRootDir#testRecursiveRootListing: "Can not create a Path from an empty string". Contributed by Steve Loughran (cherry picked from commit 3fd844b99fdfae6be6e5e261f371d175aad14229) --- .../org/apache/hadoop/fs/s3native/NativeS3FileSystem.java | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/hadoop-tools/hadoop-aws/src/main/java/org/apache/hadoop/fs/s3native/NativeS3FileSystem.java b/hadoop-tools/hadoop-aws/src/main/java/org/apache/hadoop/fs/s3native/NativeS3FileSystem.java index 9ae1061e107..e4e60375dd6 100644 --- a/hadoop-tools/hadoop-aws/src/main/java/org/apache/hadoop/fs/s3native/NativeS3FileSystem.java +++ b/hadoop-tools/hadoop-aws/src/main/java/org/apache/hadoop/fs/s3native/NativeS3FileSystem.java @@ -574,7 +574,12 @@ else if (relativePath.endsWith(FOLDER_SUFFIX)) { for (String commonPrefix : listing.getCommonPrefixes()) { Path subpath = keyToPath(commonPrefix); String relativePath = pathUri.relativize(subpath.toUri()).getPath(); - status.add(newDirectory(new Path(absolutePath, relativePath))); + // sometimes the common prefix includes the base dir (HADOOP-13830). + // avoid that problem by detecting it and keeping it out + // of the list + if (!relativePath.isEmpty()) { + status.add(newDirectory(new Path(absolutePath, relativePath))); + } } priorLastKey = listing.getPriorLastKey(); } while (priorLastKey != null);