From 0293279c583d046c0dc7ee97783981458c267cae Mon Sep 17 00:00:00 2001 From: Steve Loughran Date: Mon, 2 Dec 2013 11:00:00 +0000 Subject: [PATCH] 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/branches/branch-2@1546957 13f79535-47bb-0310-9956-ffa450edef68 --- hadoop-common-project/hadoop-common/CHANGES.txt | 3 +++ .../apache/hadoop/fs/swift/util/SwiftObjectPath.java | 6 +++++- .../apache/hadoop/fs/swift/TestSwiftObjectPath.java | 12 ++++++++++++ 3 files changed, 20 insertions(+), 1 deletion(-) diff --git a/hadoop-common-project/hadoop-common/CHANGES.txt b/hadoop-common-project/hadoop-common/CHANGES.txt index 03f4cebdde1..eadc3b81e2b 100644 --- a/hadoop-common-project/hadoop-common/CHANGES.txt +++ b/hadoop-common-project/hadoop-common/CHANGES.txt @@ -161,6 +161,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 diff --git a/hadoop-tools/hadoop-openstack/src/main/java/org/apache/hadoop/fs/swift/util/SwiftObjectPath.java b/hadoop-tools/hadoop-openstack/src/main/java/org/apache/hadoop/fs/swift/util/SwiftObjectPath.java index 264f6d9cc18..791509a9e03 100644 --- a/hadoop-tools/hadoop-openstack/src/main/java/org/apache/hadoop/fs/swift/util/SwiftObjectPath.java +++ b/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(); } diff --git a/hadoop-tools/hadoop-openstack/src/test/java/org/apache/hadoop/fs/swift/TestSwiftObjectPath.java b/hadoop-tools/hadoop-openstack/src/test/java/org/apache/hadoop/fs/swift/TestSwiftObjectPath.java index cb6ba09ef44..338763cfe84 100644 --- a/hadoop-tools/hadoop-openstack/src/test/java/org/apache/hadoop/fs/swift/TestSwiftObjectPath.java +++ b/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";