You are viewing a plain text version of this content. The canonical link for it is here.
Posted to common-commits@hadoop.apache.org by vi...@apache.org on 2016/06/20 07:18:45 UTC
[1/4] hadoop git commit: HDFS-10474. hftp copy fails when file name
with Chinese+special char in branch-2 (Contributed by Brahma Reddy Battula)
Repository: hadoop
Updated Branches:
refs/heads/branch-2 ea4cab233 -> 3f27f4050
refs/heads/branch-2.7 138d0f0bc -> be94ed6ce
refs/heads/branch-2.7.3 de32cf3c7 -> bb0a2f0cf
refs/heads/branch-2.8 55658dcaa -> 9d27530c3
HDFS-10474. hftp copy fails when file name with Chinese+special char in branch-2 (Contributed by Brahma Reddy Battula)
Project: http://git-wip-us.apache.org/repos/asf/hadoop/repo
Commit: http://git-wip-us.apache.org/repos/asf/hadoop/commit/3f27f405
Tree: http://git-wip-us.apache.org/repos/asf/hadoop/tree/3f27f405
Diff: http://git-wip-us.apache.org/repos/asf/hadoop/diff/3f27f405
Branch: refs/heads/branch-2
Commit: 3f27f405039926bbee4b36a60d6cecdb6322fff5
Parents: ea4cab2
Author: Brahma Reddy Battula <br...@apache.org>
Authored: Mon Jun 20 12:38:18 2016 +0530
Committer: Brahma Reddy Battula <br...@apache.org>
Committed: Mon Jun 20 12:38:18 2016 +0530
----------------------------------------------------------------------
.../java/org/apache/hadoop/util/ServletUtil.java | 15 +++++++++++++++
.../org/apache/hadoop/hdfs/web/HftpFileSystem.java | 6 ++++--
.../hdfs/server/namenode/ListPathsServlet.java | 2 +-
.../apache/hadoop/hdfs/web/TestHftpFileSystem.java | 2 +-
4 files changed, 21 insertions(+), 4 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/hadoop/blob/3f27f405/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/util/ServletUtil.java
----------------------------------------------------------------------
diff --git a/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/util/ServletUtil.java b/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/util/ServletUtil.java
index 3e3955b..4b12a2d 100644
--- a/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/util/ServletUtil.java
+++ b/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/util/ServletUtil.java
@@ -115,6 +115,21 @@ public class ServletUtil {
}
/**
+ * Decode a string regarded as the path component of an URI.
+ *
+ * @param path the path component to decode
+ * @return decoded path, null if UTF-8 is not supported
+ * @throws URISyntaxException
+ */
+ public static String decodePath(final String path) {
+ try {
+ return new URI(path).getPath();
+ } catch (URISyntaxException e) {
+ throw new AssertionError("Failed to decode URI: " + path);
+ }
+ }
+
+ /**
* Parse and decode the path component from the given request.
* @param request Http request to parse
* @param servletName the name of servlet that precedes the path
http://git-wip-us.apache.org/repos/asf/hadoop/blob/3f27f405/hadoop-hdfs-project/hadoop-hdfs-client/src/main/java/org/apache/hadoop/hdfs/web/HftpFileSystem.java
----------------------------------------------------------------------
diff --git a/hadoop-hdfs-project/hadoop-hdfs-client/src/main/java/org/apache/hadoop/hdfs/web/HftpFileSystem.java b/hadoop-hdfs-project/hadoop-hdfs-client/src/main/java/org/apache/hadoop/hdfs/web/HftpFileSystem.java
index cafe3cb..63b7931 100644
--- a/hadoop-hdfs-project/hadoop-hdfs-client/src/main/java/org/apache/hadoop/hdfs/web/HftpFileSystem.java
+++ b/hadoop-hdfs-project/hadoop-hdfs-client/src/main/java/org/apache/hadoop/hdfs/web/HftpFileSystem.java
@@ -442,12 +442,14 @@ public class HftpFileSystem extends FileSystem
modif, atime, FsPermission.valueOf(attrs.getValue("permission")),
attrs.getValue("owner"), attrs.getValue("group"),
HftpFileSystem.this.makeQualified(
- new Path(getUri().toString(), attrs.getValue("path"))))
+ new Path(getUri().toString(), ServletUtil.decodePath(
+ attrs.getValue("path")))))
: new FileStatus(0L, true, 0, 0L,
modif, atime, FsPermission.valueOf(attrs.getValue("permission")),
attrs.getValue("owner"), attrs.getValue("group"),
HftpFileSystem.this.makeQualified(
- new Path(getUri().toString(), attrs.getValue("path"))));
+ new Path(getUri().toString(), ServletUtil.decodePath(
+ attrs.getValue("path")))));
fslist.add(fs);
}
http://git-wip-us.apache.org/repos/asf/hadoop/blob/3f27f405/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/ListPathsServlet.java
----------------------------------------------------------------------
diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/ListPathsServlet.java b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/ListPathsServlet.java
index fcf25f5..f6ac6ca 100644
--- a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/ListPathsServlet.java
+++ b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/ListPathsServlet.java
@@ -69,7 +69,7 @@ public class ListPathsServlet extends DfsServlet {
final XMLOutputter doc) throws IOException {
final SimpleDateFormat ldf = df.get();
doc.startTag(i.isDir() ? "directory" : "file");
- doc.attribute("path", fullpath.toUri().getPath());
+ doc.attribute("path", ServletUtil.encodePath(fullpath.toUri().getPath()));
doc.attribute("modified", ldf.format(new Date(i.getModificationTime())));
doc.attribute("accesstime", ldf.format(new Date(i.getAccessTime())));
if (!i.isDir()) {
http://git-wip-us.apache.org/repos/asf/hadoop/blob/3f27f405/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/web/TestHftpFileSystem.java
----------------------------------------------------------------------
diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/web/TestHftpFileSystem.java b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/web/TestHftpFileSystem.java
index 09bc9b3..245e721 100644
--- a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/web/TestHftpFileSystem.java
+++ b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/web/TestHftpFileSystem.java
@@ -83,7 +83,7 @@ public class TestHftpFileSystem {
// URI percent encodes, Request#getPathInfo decodes
new Path("/foo bar/foo bar"), new Path("/foo?bar/foo?bar"),
- new Path("/foo\">bar/foo\">bar"), };
+ new Path("/foo\">bar/foo\">bar"), new Path("/\u8282\u8282\u9ad8@2X.png"), };
@BeforeClass
public static void setUp() throws Exception {
---------------------------------------------------------------------
To unsubscribe, e-mail: common-commits-unsubscribe@hadoop.apache.org
For additional commands, e-mail: common-commits-help@hadoop.apache.org
[4/4] hadoop git commit: HDFS-10474. hftp copy fails when file name
with Chinese+special char in branch-2 (Contributed by Brahma Reddy Battula)
Posted by vi...@apache.org.
HDFS-10474. hftp copy fails when file name with Chinese+special char in branch-2 (Contributed by Brahma Reddy Battula)
(cherry picked from commit be94ed6cebe40df99316c8f3d3086f359dd61242)
Project: http://git-wip-us.apache.org/repos/asf/hadoop/repo
Commit: http://git-wip-us.apache.org/repos/asf/hadoop/commit/bb0a2f0c
Tree: http://git-wip-us.apache.org/repos/asf/hadoop/tree/bb0a2f0c
Diff: http://git-wip-us.apache.org/repos/asf/hadoop/diff/bb0a2f0c
Branch: refs/heads/branch-2.7.3
Commit: bb0a2f0cf9b177c962761b3270974a318717803f
Parents: de32cf3
Author: Brahma Reddy Battula <br...@apache.org>
Authored: Mon Jun 20 12:43:18 2016 +0530
Committer: Brahma Reddy Battula <br...@apache.org>
Committed: Mon Jun 20 12:44:46 2016 +0530
----------------------------------------------------------------------
.../java/org/apache/hadoop/util/ServletUtil.java | 17 +++++++++++++++++
hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt | 3 +++
.../hdfs/server/namenode/ListPathsServlet.java | 2 +-
.../org/apache/hadoop/hdfs/web/HftpFileSystem.java | 6 ++++--
.../apache/hadoop/hdfs/web/TestHftpFileSystem.java | 2 +-
5 files changed, 26 insertions(+), 4 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/hadoop/blob/bb0a2f0c/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/util/ServletUtil.java
----------------------------------------------------------------------
diff --git a/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/util/ServletUtil.java b/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/util/ServletUtil.java
index 02f5401..90308b4 100644
--- a/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/util/ServletUtil.java
+++ b/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/util/ServletUtil.java
@@ -18,6 +18,8 @@
package org.apache.hadoop.util;
import java.io.*;
+import java.net.URI;
+import java.net.URISyntaxException;
import java.util.Calendar;
import javax.servlet.*;
@@ -114,6 +116,21 @@ public class ServletUtil {
}
/**
+ * Decode a string regarded as the path component of an URI.
+ *
+ * @param path the path component to decode
+ * @return decoded path, null if UTF-8 is not supported
+ * @throws URISyntaxException
+ */
+ public static String decodePath(final String path) {
+ try {
+ return new URI(path).getPath();
+ } catch (URISyntaxException e) {
+ throw new AssertionError("Failed to decode URI: " + path);
+ }
+ }
+
+ /**
* Parse and decode the path component from the given request.
* @param request Http request to parse
* @param servletName the name of servlet that precedes the path
http://git-wip-us.apache.org/repos/asf/hadoop/blob/bb0a2f0c/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt
----------------------------------------------------------------------
diff --git a/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt b/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt
index df338df..c1b91c1 100644
--- a/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt
+++ b/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt
@@ -186,6 +186,9 @@ Release 2.7.3 - UNRELEASED
HDFS-8581. ContentSummary on / skips further counts on yielding lock
(J.Andreina via vinayakumarb)
+ HDFS-10474. hftp copy fails when file name with Chinese+special char
+ in branch-2 (Brahma Reddy Battula)
+
Release 2.7.2 - 2016-01-25
INCOMPATIBLE CHANGES
http://git-wip-us.apache.org/repos/asf/hadoop/blob/bb0a2f0c/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/ListPathsServlet.java
----------------------------------------------------------------------
diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/ListPathsServlet.java b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/ListPathsServlet.java
index fcf25f5..f6ac6ca 100644
--- a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/ListPathsServlet.java
+++ b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/ListPathsServlet.java
@@ -69,7 +69,7 @@ public class ListPathsServlet extends DfsServlet {
final XMLOutputter doc) throws IOException {
final SimpleDateFormat ldf = df.get();
doc.startTag(i.isDir() ? "directory" : "file");
- doc.attribute("path", fullpath.toUri().getPath());
+ doc.attribute("path", ServletUtil.encodePath(fullpath.toUri().getPath()));
doc.attribute("modified", ldf.format(new Date(i.getModificationTime())));
doc.attribute("accesstime", ldf.format(new Date(i.getAccessTime())));
if (!i.isDir()) {
http://git-wip-us.apache.org/repos/asf/hadoop/blob/bb0a2f0c/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/web/HftpFileSystem.java
----------------------------------------------------------------------
diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/web/HftpFileSystem.java b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/web/HftpFileSystem.java
index 581f088..3e878f5 100644
--- a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/web/HftpFileSystem.java
+++ b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/web/HftpFileSystem.java
@@ -443,12 +443,14 @@ public class HftpFileSystem extends FileSystem
modif, atime, FsPermission.valueOf(attrs.getValue("permission")),
attrs.getValue("owner"), attrs.getValue("group"),
HftpFileSystem.this.makeQualified(
- new Path(getUri().toString(), attrs.getValue("path"))))
+ new Path(getUri().toString(), ServletUtil.decodePath(
+ attrs.getValue("path")))))
: new FileStatus(0L, true, 0, 0L,
modif, atime, FsPermission.valueOf(attrs.getValue("permission")),
attrs.getValue("owner"), attrs.getValue("group"),
HftpFileSystem.this.makeQualified(
- new Path(getUri().toString(), attrs.getValue("path"))));
+ new Path(getUri().toString(), ServletUtil.decodePath(
+ attrs.getValue("path")))));
fslist.add(fs);
}
http://git-wip-us.apache.org/repos/asf/hadoop/blob/bb0a2f0c/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/web/TestHftpFileSystem.java
----------------------------------------------------------------------
diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/web/TestHftpFileSystem.java b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/web/TestHftpFileSystem.java
index 19c54ef..c1faca6 100644
--- a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/web/TestHftpFileSystem.java
+++ b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/web/TestHftpFileSystem.java
@@ -82,7 +82,7 @@ public class TestHftpFileSystem {
// URI percent encodes, Request#getPathInfo decodes
new Path("/foo bar/foo bar"), new Path("/foo?bar/foo?bar"),
- new Path("/foo\">bar/foo\">bar"), };
+ new Path("/foo\">bar/foo\">bar"), new Path("/\u8282\u8282\u9ad8@2X.png"), };
@BeforeClass
public static void setUp() throws Exception {
---------------------------------------------------------------------
To unsubscribe, e-mail: common-commits-unsubscribe@hadoop.apache.org
For additional commands, e-mail: common-commits-help@hadoop.apache.org
[3/4] hadoop git commit: HDFS-10474. hftp copy fails when file name
with Chinese+special char in branch-2 (Contributed by Brahma Reddy Battula)
Posted by vi...@apache.org.
HDFS-10474. hftp copy fails when file name with Chinese+special char in branch-2 (Contributed by Brahma Reddy Battula)
Project: http://git-wip-us.apache.org/repos/asf/hadoop/repo
Commit: http://git-wip-us.apache.org/repos/asf/hadoop/commit/be94ed6c
Tree: http://git-wip-us.apache.org/repos/asf/hadoop/tree/be94ed6c
Diff: http://git-wip-us.apache.org/repos/asf/hadoop/diff/be94ed6c
Branch: refs/heads/branch-2.7
Commit: be94ed6cebe40df99316c8f3d3086f359dd61242
Parents: 138d0f0
Author: Brahma Reddy Battula <br...@apache.org>
Authored: Mon Jun 20 12:43:18 2016 +0530
Committer: Brahma Reddy Battula <br...@apache.org>
Committed: Mon Jun 20 12:43:18 2016 +0530
----------------------------------------------------------------------
.../java/org/apache/hadoop/util/ServletUtil.java | 17 +++++++++++++++++
hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt | 3 +++
.../hdfs/server/namenode/ListPathsServlet.java | 2 +-
.../org/apache/hadoop/hdfs/web/HftpFileSystem.java | 6 ++++--
.../apache/hadoop/hdfs/web/TestHftpFileSystem.java | 2 +-
5 files changed, 26 insertions(+), 4 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/hadoop/blob/be94ed6c/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/util/ServletUtil.java
----------------------------------------------------------------------
diff --git a/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/util/ServletUtil.java b/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/util/ServletUtil.java
index 02f5401..90308b4 100644
--- a/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/util/ServletUtil.java
+++ b/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/util/ServletUtil.java
@@ -18,6 +18,8 @@
package org.apache.hadoop.util;
import java.io.*;
+import java.net.URI;
+import java.net.URISyntaxException;
import java.util.Calendar;
import javax.servlet.*;
@@ -114,6 +116,21 @@ public class ServletUtil {
}
/**
+ * Decode a string regarded as the path component of an URI.
+ *
+ * @param path the path component to decode
+ * @return decoded path, null if UTF-8 is not supported
+ * @throws URISyntaxException
+ */
+ public static String decodePath(final String path) {
+ try {
+ return new URI(path).getPath();
+ } catch (URISyntaxException e) {
+ throw new AssertionError("Failed to decode URI: " + path);
+ }
+ }
+
+ /**
* Parse and decode the path component from the given request.
* @param request Http request to parse
* @param servletName the name of servlet that precedes the path
http://git-wip-us.apache.org/repos/asf/hadoop/blob/be94ed6c/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt
----------------------------------------------------------------------
diff --git a/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt b/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt
index df338df..c1b91c1 100644
--- a/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt
+++ b/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt
@@ -186,6 +186,9 @@ Release 2.7.3 - UNRELEASED
HDFS-8581. ContentSummary on / skips further counts on yielding lock
(J.Andreina via vinayakumarb)
+ HDFS-10474. hftp copy fails when file name with Chinese+special char
+ in branch-2 (Brahma Reddy Battula)
+
Release 2.7.2 - 2016-01-25
INCOMPATIBLE CHANGES
http://git-wip-us.apache.org/repos/asf/hadoop/blob/be94ed6c/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/ListPathsServlet.java
----------------------------------------------------------------------
diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/ListPathsServlet.java b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/ListPathsServlet.java
index fcf25f5..f6ac6ca 100644
--- a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/ListPathsServlet.java
+++ b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/ListPathsServlet.java
@@ -69,7 +69,7 @@ public class ListPathsServlet extends DfsServlet {
final XMLOutputter doc) throws IOException {
final SimpleDateFormat ldf = df.get();
doc.startTag(i.isDir() ? "directory" : "file");
- doc.attribute("path", fullpath.toUri().getPath());
+ doc.attribute("path", ServletUtil.encodePath(fullpath.toUri().getPath()));
doc.attribute("modified", ldf.format(new Date(i.getModificationTime())));
doc.attribute("accesstime", ldf.format(new Date(i.getAccessTime())));
if (!i.isDir()) {
http://git-wip-us.apache.org/repos/asf/hadoop/blob/be94ed6c/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/web/HftpFileSystem.java
----------------------------------------------------------------------
diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/web/HftpFileSystem.java b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/web/HftpFileSystem.java
index 581f088..3e878f5 100644
--- a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/web/HftpFileSystem.java
+++ b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/web/HftpFileSystem.java
@@ -443,12 +443,14 @@ public class HftpFileSystem extends FileSystem
modif, atime, FsPermission.valueOf(attrs.getValue("permission")),
attrs.getValue("owner"), attrs.getValue("group"),
HftpFileSystem.this.makeQualified(
- new Path(getUri().toString(), attrs.getValue("path"))))
+ new Path(getUri().toString(), ServletUtil.decodePath(
+ attrs.getValue("path")))))
: new FileStatus(0L, true, 0, 0L,
modif, atime, FsPermission.valueOf(attrs.getValue("permission")),
attrs.getValue("owner"), attrs.getValue("group"),
HftpFileSystem.this.makeQualified(
- new Path(getUri().toString(), attrs.getValue("path"))));
+ new Path(getUri().toString(), ServletUtil.decodePath(
+ attrs.getValue("path")))));
fslist.add(fs);
}
http://git-wip-us.apache.org/repos/asf/hadoop/blob/be94ed6c/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/web/TestHftpFileSystem.java
----------------------------------------------------------------------
diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/web/TestHftpFileSystem.java b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/web/TestHftpFileSystem.java
index 19c54ef..c1faca6 100644
--- a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/web/TestHftpFileSystem.java
+++ b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/web/TestHftpFileSystem.java
@@ -82,7 +82,7 @@ public class TestHftpFileSystem {
// URI percent encodes, Request#getPathInfo decodes
new Path("/foo bar/foo bar"), new Path("/foo?bar/foo?bar"),
- new Path("/foo\">bar/foo\">bar"), };
+ new Path("/foo\">bar/foo\">bar"), new Path("/\u8282\u8282\u9ad8@2X.png"), };
@BeforeClass
public static void setUp() throws Exception {
---------------------------------------------------------------------
To unsubscribe, e-mail: common-commits-unsubscribe@hadoop.apache.org
For additional commands, e-mail: common-commits-help@hadoop.apache.org
[2/4] hadoop git commit: HDFS-10474. hftp copy fails when file name
with Chinese+special char in branch-2 (Contributed by Brahma Reddy Battula)
Posted by vi...@apache.org.
HDFS-10474. hftp copy fails when file name with Chinese+special char in branch-2 (Contributed by Brahma Reddy Battula)
(cherry picked from commit 3f27f405039926bbee4b36a60d6cecdb6322fff5)
Project: http://git-wip-us.apache.org/repos/asf/hadoop/repo
Commit: http://git-wip-us.apache.org/repos/asf/hadoop/commit/9d27530c
Tree: http://git-wip-us.apache.org/repos/asf/hadoop/tree/9d27530c
Diff: http://git-wip-us.apache.org/repos/asf/hadoop/diff/9d27530c
Branch: refs/heads/branch-2.8
Commit: 9d27530c36c61da5e9ead617a23f43f1b0f7e4ac
Parents: 55658dc
Author: Brahma Reddy Battula <br...@apache.org>
Authored: Mon Jun 20 12:38:18 2016 +0530
Committer: Brahma Reddy Battula <br...@apache.org>
Committed: Mon Jun 20 12:40:11 2016 +0530
----------------------------------------------------------------------
.../java/org/apache/hadoop/util/ServletUtil.java | 15 +++++++++++++++
.../org/apache/hadoop/hdfs/web/HftpFileSystem.java | 6 ++++--
.../hdfs/server/namenode/ListPathsServlet.java | 2 +-
.../apache/hadoop/hdfs/web/TestHftpFileSystem.java | 2 +-
4 files changed, 21 insertions(+), 4 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/hadoop/blob/9d27530c/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/util/ServletUtil.java
----------------------------------------------------------------------
diff --git a/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/util/ServletUtil.java b/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/util/ServletUtil.java
index 3e3955b..4b12a2d 100644
--- a/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/util/ServletUtil.java
+++ b/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/util/ServletUtil.java
@@ -115,6 +115,21 @@ public class ServletUtil {
}
/**
+ * Decode a string regarded as the path component of an URI.
+ *
+ * @param path the path component to decode
+ * @return decoded path, null if UTF-8 is not supported
+ * @throws URISyntaxException
+ */
+ public static String decodePath(final String path) {
+ try {
+ return new URI(path).getPath();
+ } catch (URISyntaxException e) {
+ throw new AssertionError("Failed to decode URI: " + path);
+ }
+ }
+
+ /**
* Parse and decode the path component from the given request.
* @param request Http request to parse
* @param servletName the name of servlet that precedes the path
http://git-wip-us.apache.org/repos/asf/hadoop/blob/9d27530c/hadoop-hdfs-project/hadoop-hdfs-client/src/main/java/org/apache/hadoop/hdfs/web/HftpFileSystem.java
----------------------------------------------------------------------
diff --git a/hadoop-hdfs-project/hadoop-hdfs-client/src/main/java/org/apache/hadoop/hdfs/web/HftpFileSystem.java b/hadoop-hdfs-project/hadoop-hdfs-client/src/main/java/org/apache/hadoop/hdfs/web/HftpFileSystem.java
index cafe3cb..63b7931 100644
--- a/hadoop-hdfs-project/hadoop-hdfs-client/src/main/java/org/apache/hadoop/hdfs/web/HftpFileSystem.java
+++ b/hadoop-hdfs-project/hadoop-hdfs-client/src/main/java/org/apache/hadoop/hdfs/web/HftpFileSystem.java
@@ -442,12 +442,14 @@ public class HftpFileSystem extends FileSystem
modif, atime, FsPermission.valueOf(attrs.getValue("permission")),
attrs.getValue("owner"), attrs.getValue("group"),
HftpFileSystem.this.makeQualified(
- new Path(getUri().toString(), attrs.getValue("path"))))
+ new Path(getUri().toString(), ServletUtil.decodePath(
+ attrs.getValue("path")))))
: new FileStatus(0L, true, 0, 0L,
modif, atime, FsPermission.valueOf(attrs.getValue("permission")),
attrs.getValue("owner"), attrs.getValue("group"),
HftpFileSystem.this.makeQualified(
- new Path(getUri().toString(), attrs.getValue("path"))));
+ new Path(getUri().toString(), ServletUtil.decodePath(
+ attrs.getValue("path")))));
fslist.add(fs);
}
http://git-wip-us.apache.org/repos/asf/hadoop/blob/9d27530c/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/ListPathsServlet.java
----------------------------------------------------------------------
diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/ListPathsServlet.java b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/ListPathsServlet.java
index fcf25f5..f6ac6ca 100644
--- a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/ListPathsServlet.java
+++ b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/ListPathsServlet.java
@@ -69,7 +69,7 @@ public class ListPathsServlet extends DfsServlet {
final XMLOutputter doc) throws IOException {
final SimpleDateFormat ldf = df.get();
doc.startTag(i.isDir() ? "directory" : "file");
- doc.attribute("path", fullpath.toUri().getPath());
+ doc.attribute("path", ServletUtil.encodePath(fullpath.toUri().getPath()));
doc.attribute("modified", ldf.format(new Date(i.getModificationTime())));
doc.attribute("accesstime", ldf.format(new Date(i.getAccessTime())));
if (!i.isDir()) {
http://git-wip-us.apache.org/repos/asf/hadoop/blob/9d27530c/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/web/TestHftpFileSystem.java
----------------------------------------------------------------------
diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/web/TestHftpFileSystem.java b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/web/TestHftpFileSystem.java
index 09bc9b3..245e721 100644
--- a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/web/TestHftpFileSystem.java
+++ b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/web/TestHftpFileSystem.java
@@ -83,7 +83,7 @@ public class TestHftpFileSystem {
// URI percent encodes, Request#getPathInfo decodes
new Path("/foo bar/foo bar"), new Path("/foo?bar/foo?bar"),
- new Path("/foo\">bar/foo\">bar"), };
+ new Path("/foo\">bar/foo\">bar"), new Path("/\u8282\u8282\u9ad8@2X.png"), };
@BeforeClass
public static void setUp() throws Exception {
---------------------------------------------------------------------
To unsubscribe, e-mail: common-commits-unsubscribe@hadoop.apache.org
For additional commands, e-mail: common-commits-help@hadoop.apache.org