hbase-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From st...@apache.org
Subject hbase git commit: HBASE-12491 TableMapReduceUtil.findContainingJar() NPE
Date Sat, 29 Nov 2014 17:34:36 GMT
Repository: hbase
Updated Branches:
  refs/heads/branch-1 b12d57783 -> 84d9f0ec2


HBASE-12491 TableMapReduceUtil.findContainingJar() NPE


Project: http://git-wip-us.apache.org/repos/asf/hbase/repo
Commit: http://git-wip-us.apache.org/repos/asf/hbase/commit/84d9f0ec
Tree: http://git-wip-us.apache.org/repos/asf/hbase/tree/84d9f0ec
Diff: http://git-wip-us.apache.org/repos/asf/hbase/diff/84d9f0ec

Branch: refs/heads/branch-1
Commit: 84d9f0ec26df99b96358ff26c731bb2157e672f1
Parents: b12d577
Author: stack <stack@apache.org>
Authored: Sat Nov 29 09:34:00 2014 -0800
Committer: stack <stack@apache.org>
Committed: Sat Nov 29 09:34:25 2014 -0800

----------------------------------------------------------------------
 .../hbase/mapreduce/TableMapReduceUtil.java     | 35 +++++++++++---------
 1 file changed, 19 insertions(+), 16 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/hbase/blob/84d9f0ec/hbase-server/src/main/java/org/apache/hadoop/hbase/mapreduce/TableMapReduceUtil.java
----------------------------------------------------------------------
diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/mapreduce/TableMapReduceUtil.java
b/hbase-server/src/main/java/org/apache/hadoop/hbase/mapreduce/TableMapReduceUtil.java
index ebe7d36..b514941 100644
--- a/hbase-server/src/main/java/org/apache/hadoop/hbase/mapreduce/TableMapReduceUtil.java
+++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/mapreduce/TableMapReduceUtil.java
@@ -900,25 +900,28 @@ public class TableMapReduceUtil {
   private static String findContainingJar(Class<?> my_class, Map<String, String>
packagedClasses)
       throws IOException {
     ClassLoader loader = my_class.getClassLoader();
+
     String class_file = my_class.getName().replaceAll("\\.", "/") + ".class";
 
-    // first search the classpath
-    for (Enumeration<URL> itr = loader.getResources(class_file); itr.hasMoreElements();)
{
-      URL url = itr.nextElement();
-      if ("jar".equals(url.getProtocol())) {
-        String toReturn = url.getPath();
-        if (toReturn.startsWith("file:")) {
-          toReturn = toReturn.substring("file:".length());
+    if (loader != null) {
+      // first search the classpath
+      for (Enumeration<URL> itr = loader.getResources(class_file); itr.hasMoreElements();)
{
+        URL url = itr.nextElement();
+        if ("jar".equals(url.getProtocol())) {
+          String toReturn = url.getPath();
+          if (toReturn.startsWith("file:")) {
+            toReturn = toReturn.substring("file:".length());
+          }
+          // URLDecoder is a misnamed class, since it actually decodes
+          // x-www-form-urlencoded MIME type rather than actual
+          // URL encoding (which the file path has). Therefore it would
+          // decode +s to ' 's which is incorrect (spaces are actually
+          // either unencoded or encoded as "%20"). Replace +s first, so
+          // that they are kept sacred during the decoding process.
+          toReturn = toReturn.replaceAll("\\+", "%2B");
+          toReturn = URLDecoder.decode(toReturn, "UTF-8");
+          return toReturn.replaceAll("!.*$", "");
         }
-        // URLDecoder is a misnamed class, since it actually decodes
-        // x-www-form-urlencoded MIME type rather than actual
-        // URL encoding (which the file path has). Therefore it would
-        // decode +s to ' 's which is incorrect (spaces are actually
-        // either unencoded or encoded as "%20"). Replace +s first, so
-        // that they are kept sacred during the decoding process.
-        toReturn = toReturn.replaceAll("\\+", "%2B");
-        toReturn = URLDecoder.decode(toReturn, "UTF-8");
-        return toReturn.replaceAll("!.*$", "");
       }
     }
 


Mime
View raw message