From 7b60e94c098ac74eebdb6371c0e211345f17f00c Mon Sep 17 00:00:00 2001 From: Steve Loughran Date: Mon, 2 Dec 2013 11:03: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/trunk@1546959 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 8dff925d86..dbb5b72553 100644 --- a/hadoop-common-project/hadoop-common/CHANGES.txt +++ b/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 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 264f6d9cc1..791509a9e0 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 cb6ba09ef4..338763cfe8 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 void testParseUrlPath() throws Exception { 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";