hadoop-common-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From iwasak...@apache.org
Subject hadoop git commit: HADOOP-12711. Remove dependency on commons-httpclient for ServletUtil (Wei-Chiu Chuang via iwasakims)
Date Fri, 26 Feb 2016 06:36:27 GMT
Repository: hadoop
Updated Branches:
  refs/heads/branch-2.8 6e9a4c598 -> 7140a0212


HADOOP-12711. Remove dependency on commons-httpclient for ServletUtil (Wei-Chiu Chuang via
iwasakims)

(cherry picked from commit b0091338f2ffea0fb16fed01c44f911490d94c70)


Project: http://git-wip-us.apache.org/repos/asf/hadoop/repo
Commit: http://git-wip-us.apache.org/repos/asf/hadoop/commit/7140a021
Tree: http://git-wip-us.apache.org/repos/asf/hadoop/tree/7140a021
Diff: http://git-wip-us.apache.org/repos/asf/hadoop/diff/7140a021

Branch: refs/heads/branch-2.8
Commit: 7140a02122fb9fe51c499b44ac0c6ba4b06023bf
Parents: 6e9a4c5
Author: Masatake Iwasaki <iwasakims@apache.org>
Authored: Fri Feb 26 15:32:07 2016 +0900
Committer: Masatake Iwasaki <iwasakims@apache.org>
Committed: Fri Feb 26 15:33:21 2016 +0900

----------------------------------------------------------------------
 hadoop-common-project/hadoop-common/CHANGES.txt |  3 ++
 .../org/apache/hadoop/util/ServletUtil.java     | 34 +++++++++++---------
 2 files changed, 22 insertions(+), 15 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/hadoop/blob/7140a021/hadoop-common-project/hadoop-common/CHANGES.txt
----------------------------------------------------------------------
diff --git a/hadoop-common-project/hadoop-common/CHANGES.txt b/hadoop-common-project/hadoop-common/CHANGES.txt
index 6ddfee1..cdd4125 100644
--- a/hadoop-common-project/hadoop-common/CHANGES.txt
+++ b/hadoop-common-project/hadoop-common/CHANGES.txt
@@ -429,6 +429,9 @@ Release 2.8.0 - UNRELEASED
     HADOOP-12824. Collect network and disk usage on the node running Windows.
     (Inigo Goiri via xyao)
 
+    HADOOP-12711. Remove dependency on commons-httpclient for ServletUtil
+    (Wei-Chiu Chuang via iwasakims)
+
   OPTIMIZATIONS
 
     HADOOP-11785. Reduce the number of listStatus operation in distcp

http://git-wip-us.apache.org/repos/asf/hadoop/blob/7140a021/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..3e3955b 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
@@ -17,18 +17,22 @@
  */
 package org.apache.hadoop.util;
 
-import java.io.*;
+import java.io.IOException;
+import java.io.PrintWriter;
+import java.io.UnsupportedEncodingException;
+import java.net.URI;
+import java.net.URISyntaxException;
+import java.net.URLEncoder;
 import java.util.Calendar;
 
 import javax.servlet.*;
 import javax.servlet.http.HttpServletRequest;
 
-import org.apache.commons.httpclient.URIException;
-import org.apache.commons.httpclient.util.URIUtil;
 import org.apache.hadoop.classification.InterfaceAudience;
 import org.apache.hadoop.classification.InterfaceStability;
 
 import com.google.common.base.Preconditions;
+import org.apache.http.client.utils.URIBuilder;
 
 @InterfaceAudience.Private
 @InterfaceStability.Unstable
@@ -94,9 +98,10 @@ public class ServletUtil {
    */
   public static String encodeQueryValue(final String value) {
     try {
-      return URIUtil.encodeWithinQuery(value, "UTF-8");
-    } catch (URIException e) {
-      throw new AssertionError("JVM does not support UTF-8"); // should never happen!
+      return URLEncoder.encode(value, "UTF-8");
+    } catch (UnsupportedEncodingException e) {
+      throw new AssertionError("Failed to encode query value in UTF-8: " +
+          value);
     }
   }
 
@@ -106,11 +111,7 @@ public class ServletUtil {
    * @return encoded path, null if UTF-8 is not supported
    */
   public static String encodePath(final String path) {
-    try {
-      return URIUtil.encodePath(path, "UTF-8");
-    } catch (URIException e) {
-      throw new AssertionError("JVM does not support UTF-8"); // should never happen!
-    }
+    return new URIBuilder().setPath(path).toString();
   }
 
   /**
@@ -119,11 +120,14 @@ public class ServletUtil {
    * @param servletName the name of servlet that precedes the path
    * @return decoded path component, null if UTF-8 is not supported
    */
-  public static String getDecodedPath(final HttpServletRequest request, String servletName)
{
+  public static String getDecodedPath(final HttpServletRequest request,
+      String servletName) {
+    String requestURI = request.getRequestURI();
+    String uriPath = getRawPath(request, servletName);
     try {
-      return URIUtil.decode(getRawPath(request, servletName), "UTF-8");
-    } catch (URIException e) {
-      throw new AssertionError("JVM does not support UTF-8"); // should never happen!
+      return new URI(uriPath).getPath();
+    } catch (URISyntaxException e) {
+      throw new AssertionError("Failed to decode URI: " + requestURI);
     }
   }
 


Mime
View raw message