HBASE-12491 TableMapReduceUtil.findContainingJar() NPE

This commit is contained in:
stack 2014-11-29 09:34:00 -08:00
parent 555e78005d
commit b94b0e9ca7
1 changed files with 19 additions and 16 deletions

View File

@ -900,8 +900,10 @@ 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";
if (loader != null) {
// first search the classpath
for (Enumeration<URL> itr = loader.getResources(class_file); itr.hasMoreElements();) {
URL url = itr.nextElement();
@ -921,6 +923,7 @@ public class TableMapReduceUtil {
return toReturn.replaceAll("!.*$", "");
}
}
}
// now look in any jars we've packaged using JarFinder. Returns null when
// no jar is found.