You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@sentry.apache.org by ls...@apache.org on 2015/03/05 18:01:23 UTC

incubator-sentry git commit: SENTRY-665: PathsUpdate.parsePath needs to handle special characters (Ryan P via Lenni Kuff)

Repository: incubator-sentry
Updated Branches:
  refs/heads/master feb8cbee6 -> 90ea9aca1


SENTRY-665: PathsUpdate.parsePath needs to handle special characters (Ryan P via Lenni Kuff)


Project: http://git-wip-us.apache.org/repos/asf/incubator-sentry/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-sentry/commit/90ea9aca
Tree: http://git-wip-us.apache.org/repos/asf/incubator-sentry/tree/90ea9aca
Diff: http://git-wip-us.apache.org/repos/asf/incubator-sentry/diff/90ea9aca

Branch: refs/heads/master
Commit: 90ea9aca11cc36de90c081d70588b43386b3148a
Parents: feb8cbe
Author: Lenni Kuff <ls...@cloudera.com>
Authored: Thu Mar 5 08:59:47 2015 -0800
Committer: Lenni Kuff <ls...@cloudera.com>
Committed: Thu Mar 5 09:00:18 2015 -0800

----------------------------------------------------------------------
 .../src/main/java/org/apache/sentry/hdfs/PathsUpdate.java      | 6 +++++-
 .../src/test/java/org/apache/sentry/hdfs/TestPathsUpdate.java  | 2 +-
 2 files changed, 6 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-sentry/blob/90ea9aca/sentry-hdfs/sentry-hdfs-common/src/main/java/org/apache/sentry/hdfs/PathsUpdate.java
----------------------------------------------------------------------
diff --git a/sentry-hdfs/sentry-hdfs-common/src/main/java/org/apache/sentry/hdfs/PathsUpdate.java b/sentry-hdfs/sentry-hdfs-common/src/main/java/org/apache/sentry/hdfs/PathsUpdate.java
index 3f14bf7..7cb20ef 100644
--- a/sentry-hdfs/sentry-hdfs-common/src/main/java/org/apache/sentry/hdfs/PathsUpdate.java
+++ b/sentry-hdfs/sentry-hdfs-common/src/main/java/org/apache/sentry/hdfs/PathsUpdate.java
@@ -27,6 +27,8 @@ import com.google.common.base.Preconditions;
 
 import org.apache.sentry.hdfs.service.thrift.TPathChanges;
 import org.apache.sentry.hdfs.service.thrift.TPathsUpdate;
+import org.apache.commons.httpclient.util.URIUtil;
+import org.apache.commons.httpclient.URIException;
 
 import com.google.common.collect.Lists;
 
@@ -90,7 +92,7 @@ public class PathsUpdate implements Updateable.Update {
    */
   public static List<String> parsePath(String path) {
     try {
-      URI uri = new URI(path.replace(" ","%20"));
+      URI uri = new URI(URIUtil.encodePath(path));
       Preconditions.checkNotNull(uri.getScheme());
       if(uri.getScheme().equalsIgnoreCase("hdfs")) {
         return Lists.newArrayList(uri.getPath().split("^/")[1]
@@ -100,6 +102,8 @@ public class PathsUpdate implements Updateable.Update {
       }
     } catch (URISyntaxException e) {
       throw new RuntimeException("Incomprehensible path [" + path + "]");
+    } catch (URIException e){
+      throw new RuntimeException("Unable to create URI: ",e);
     }
   }
 

http://git-wip-us.apache.org/repos/asf/incubator-sentry/blob/90ea9aca/sentry-hdfs/sentry-hdfs-common/src/test/java/org/apache/sentry/hdfs/TestPathsUpdate.java
----------------------------------------------------------------------
diff --git a/sentry-hdfs/sentry-hdfs-common/src/test/java/org/apache/sentry/hdfs/TestPathsUpdate.java b/sentry-hdfs/sentry-hdfs-common/src/test/java/org/apache/sentry/hdfs/TestPathsUpdate.java
index db63578..5bd8487 100644
--- a/sentry-hdfs/sentry-hdfs-common/src/test/java/org/apache/sentry/hdfs/TestPathsUpdate.java
+++ b/sentry-hdfs/sentry-hdfs-common/src/test/java/org/apache/sentry/hdfs/TestPathsUpdate.java
@@ -25,7 +25,7 @@ public class TestPathsUpdate {
   @Test
   public void testParsePath(){
     List<String> results = PathsUpdate.parsePath(
-      "hdfs://hostname.test.com:8020/user/hive/warehouse/break/b=all the spaces/c=in PartKeys"
+      "hdfs://hostname.test.com:8020/user/hive/warehouse/break/b=all | ' & the spaces/c=in PartKeys/With fun chars *%!|"
     );
     System.out.println(results);
     Assert.assertNotNull("Parse path without throwing exception",results);