Browse Source

HADOOP-5805. problem using top level s3 buckets as input/output directories. Contributed by Ian Nowland.

git-svn-id: https://svn.apache.org/repos/asf/hadoop/core/trunk@779656 13f79535-47bb-0310-9956-ffa450edef68
Thomas White 16 years ago
parent
commit
a28c29c5f7

+ 3 - 0
CHANGES.txt

@@ -710,6 +710,9 @@ Trunk (unreleased changes)
     HADOOP-5895. Fixes computation of count of merged bytes for logging.
     (Ravi Gummadi via ddas)
 
+    HADOOP-5805. problem using top level s3 buckets as input/output directories.
+    (Ian Nowland via tomwhite)
+
 Release 0.20.1 - Unreleased
 
   INCOMPATIBLE CHANGES

+ 5 - 0
src/core/org/apache/hadoop/fs/s3native/NativeS3FileSystem.java

@@ -251,6 +251,11 @@ public class NativeS3FileSystem extends FileSystem {
   }
   
   private static String pathToKey(Path path) {
+    if (path.toUri().getScheme() != null && "".equals(path.toUri().getPath())) {
+      // allow uris without trailing slash after bucket to refer to root,
+      // like s3n://mybucket
+      return "";
+    }
     if (!path.isAbsolute()) {
       throw new IllegalArgumentException("Path must be absolute: " + path);
     }

+ 3 - 0
src/test/core/org/apache/hadoop/fs/s3native/NativeS3FileSystemContractBaseTest.java

@@ -56,4 +56,7 @@ public abstract class NativeS3FileSystemContractBaseTest
     assertEquals(path("/test"), paths[0].getPath());
   }
   
+  public void testNoTrailingBackslashOnBucket() throws Exception {
+    assertTrue(fs.getFileStatus(new Path(fs.getUri().toString())).isDir());
+  }
 }