HBASE-8383 Support lib/*jar inside coprocessor jar
git-svn-id: https://svn.apache.org/repos/asf/hbase/trunk@1471754 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
f11b4224fb
commit
4558ca5a79
|
@ -51,7 +51,6 @@ public class ClassLoaderBase extends URLClassLoader {
|
|||
* Creates a DynamicClassLoader that can load classes dynamically
|
||||
* from jar files under a specific folder.
|
||||
*
|
||||
* @param conf the configuration for the cluster.
|
||||
* @param parent the parent ClassLoader to set.
|
||||
*/
|
||||
public ClassLoaderBase(final ClassLoader parent) {
|
||||
|
|
|
@ -158,7 +158,7 @@ public class CoprocessorClassLoader extends ClassLoaderBase {
|
|||
Enumeration<JarEntry> entries = jarFile.entries();
|
||||
while (entries.hasMoreElements()) {
|
||||
JarEntry entry = entries.nextElement();
|
||||
if (entry.getName().matches("/lib/[^/]+\\.jar")) {
|
||||
if (entry.getName().matches("[/]?lib/[^/]+\\.jar")) {
|
||||
File file = new File(parentDir, "." + pathPrefix + "." + path.getName()
|
||||
+ "." + System.currentTimeMillis() + "." + entry.getName().substring(5));
|
||||
IOUtils.copyBytes(jarFile.getInputStream(entry), new FileOutputStream(file), conf, true);
|
||||
|
|
|
@ -382,6 +382,15 @@ public class TestClassLoading {
|
|||
|
||||
@Test
|
||||
public void testClassLoadingFromLibDirInJar() throws Exception {
|
||||
loadingClassFromLibDirInJar("/lib/");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testClassLoadingFromRelativeLibDirInJar() throws Exception {
|
||||
loadingClassFromLibDirInJar("lib/");
|
||||
}
|
||||
|
||||
void loadingClassFromLibDirInJar(String libPrefix) throws Exception {
|
||||
FileSystem fs = cluster.getFileSystem();
|
||||
|
||||
File innerJarFile1 = buildCoprocessorJar(cpName1);
|
||||
|
@ -397,7 +406,7 @@ public class TestClassLoading {
|
|||
|
||||
for (File jarFile: new File[] { innerJarFile1, innerJarFile2 }) {
|
||||
// Add archive entry
|
||||
JarEntry jarAdd = new JarEntry("/lib/" + jarFile.getName());
|
||||
JarEntry jarAdd = new JarEntry(libPrefix + jarFile.getName());
|
||||
jarAdd.setTime(jarFile.lastModified());
|
||||
out.putNextEntry(jarAdd);
|
||||
|
||||
|
|
Loading…
Reference in New Issue