Quellcode durchsuchen

HADOOP-10135 writes to swift fs over partition size leave temp files and empty output file

git-svn-id: https://svn.apache.org/repos/asf/hadoop/common/trunk@1546959 13f79535-47bb-0310-9956-ffa450edef68
Steve Loughran vor 11 Jahren
Ursprung
Commit
7b60e94c09

+ 3 - 0
hadoop-common-project/hadoop-common/CHANGES.txt

@@ -452,6 +452,9 @@ Release 2.3.0 - UNRELEASED
     HADOOP-10107. Server.getNumOpenConnections may throw NPE. (Kihwal Lee via
     jing9)
 
+    HADOOP-10135 writes to swift fs over partition size leave temp files and
+    empty output file (David Dobbins via stevel)
+
 Release 2.2.1 - UNRELEASED
 
   INCOMPATIBLE CHANGES

+ 5 - 1
hadoop-tools/hadoop-openstack/src/main/java/org/apache/hadoop/fs/swift/util/SwiftObjectPath.java

@@ -51,8 +51,12 @@ public final class SwiftObjectPath {
    */
   public SwiftObjectPath(String container, String object) {
 
+    if (object == null) {
+      throw new IllegalArgumentException("object name can't be null");
+    }
+
     this.container = container;
-    this.object = object;
+    this.object = URI.create(object).getPath();
     uriPath = buildUriPath();
   }
 

+ 12 - 0
hadoop-tools/hadoop-openstack/src/test/java/org/apache/hadoop/fs/swift/TestSwiftObjectPath.java

@@ -71,6 +71,18 @@ public class TestSwiftObjectPath implements SwiftTestConstants {
     assertEquals(expected, actual);
   }
 
+  @Test(timeout = SWIFT_TEST_TIMEOUT)
+  public void testHandleUrlAsPath() throws Exception {
+    final String hostPart = "swift://container.service1";
+    final String pathPart = "/home/user/files/file1";
+    final String uriString = hostPart + pathPart;
+
+    final SwiftObjectPath expected = new SwiftObjectPath(uriString, pathPart);
+    final SwiftObjectPath actual = new SwiftObjectPath(uriString, uriString);
+
+    assertEquals(expected, actual);
+  }
+
   @Test(timeout = SWIFT_TEST_TIMEOUT)
   public void testParseAuthenticatedUrl() throws Exception {
     final String pathString = "swift://container.service1/v2/AUTH_00345h34l93459y4/home/tom/documents/finance.docx";