From 750442812c78ba97b71e0f20c7f07c9915c6e841 Mon Sep 17 00:00:00 2001 From: Chris Nauroth Date: Sun, 30 Jun 2013 03:38:09 +0000 Subject: [PATCH] HDFS-4944. WebHDFS cannot create a file path containing characters that must be URI-encoded, such as space. Contributed by Chris Nauroth. git-svn-id: https://svn.apache.org/repos/asf/hadoop/common/trunk@1498055 13f79535-47bb-0310-9956-ffa450edef68 --- hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt | 3 ++ .../web/TestWebHdfsFileSystemContract.java | 29 +++++++++++++++++++ 2 files changed, 32 insertions(+) diff --git a/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt b/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt index 25d16820dc4..be81c83c81e 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt +++ b/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt @@ -631,6 +631,9 @@ Release 2.1.0-beta - 2013-07-02 HDFS-4927. CreateEditsLog creates inodes with an invalid inode ID, which then cannot be loaded by a namenode. (cnauroth) + HDFS-4944. WebHDFS cannot create a file path containing characters that must + be URI-encoded, such as space. (cnauroth) + BREAKDOWN OF HDFS-347 SUBTASKS AND RELATED JIRAS HDFS-4353. Encapsulate connections to peers in Peer and PeerServer classes. diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/web/TestWebHdfsFileSystemContract.java b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/web/TestWebHdfsFileSystemContract.java index bb1aea0b6f0..343aa775d0b 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/web/TestWebHdfsFileSystemContract.java +++ b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/web/TestWebHdfsFileSystemContract.java @@ -404,5 +404,34 @@ public class TestWebHdfsFileSystemContract extends FileSystemContractBaseTest { } conn.disconnect(); } + + {//test create with path containing spaces + HttpOpParam.Op op = PutOpParam.Op.CREATE; + Path path = new Path("/test/path%20with%20spaces"); + URL url = webhdfs.toUrl(op, path); + HttpURLConnection conn = (HttpURLConnection)url.openConnection(); + conn.setRequestMethod(op.getType().toString()); + conn.setDoOutput(false); + conn.setInstanceFollowRedirects(false); + final String redirect; + try { + conn.connect(); + assertEquals(HttpServletResponse.SC_TEMPORARY_REDIRECT, + conn.getResponseCode()); + redirect = conn.getHeaderField("Location"); + } finally { + conn.disconnect(); + } + + conn = (HttpURLConnection)new URL(redirect).openConnection(); + conn.setRequestMethod(op.getType().toString()); + conn.setDoOutput(op.getDoOutput()); + try { + conn.connect(); + assertEquals(HttpServletResponse.SC_CREATED, conn.getResponseCode()); + } finally { + conn.disconnect(); + } + } } }