Use proper traditional CL parent delegation.

This ultimately allows loading all JRE classes correctly, not only those
whose name are whitelisted.
This commit is contained in:
Eric Bottard
2019-08-29 18:10:50 +02:00
parent d115e2b62a
commit 339bbdca87

View File

@@ -130,20 +130,13 @@ class FunctionArchiveDeployer extends JarLauncher {
* class loader, this will ensure that certain classes (e.g., org.reactivestreams.* see #shouldLoadViaDeployerLoader() ) * class loader, this will ensure that certain classes (e.g., org.reactivestreams.* see #shouldLoadViaDeployerLoader() )
* are shared across two class loaders. * are shared across two class loaders.
*/ */
this.archiveLoader = new LaunchedURLClassLoader(urls, null) { final ClassLoader deployerClassLoader = getClass().getClassLoader();
this.archiveLoader = new LaunchedURLClassLoader(urls, deployerClassLoader.getParent()) {
@Override @Override
public Class<?> loadClass(String name) throws ClassNotFoundException { public Class<?> loadClass(String name) throws ClassNotFoundException {
Class<?> clazz = null; Class<?> clazz = null;
if (shouldLoadViaDeployerLoader(name)) { if (shouldLoadViaDeployerLoader(name)) {
try { clazz = deployerClassLoader.loadClass(name);
clazz = getClass().getClassLoader().loadClass(name);
}
catch (Exception e) {
if (logger.isDebugEnabled()) {
logger.debug("Class '" + name + "' is not available in the current class loader. Loading it from the deployed archive.");
}
clazz = super.loadClass(name, false);
}
} }
else if (name.equals(DeployerContextUtils.class.getName())) { else if (name.equals(DeployerContextUtils.class.getName())) {
/* /*
@@ -169,9 +162,7 @@ class FunctionArchiveDeployer extends JarLauncher {
private boolean shouldLoadViaDeployerLoader(String name) { private boolean shouldLoadViaDeployerLoader(String name) {
return name.startsWith("org.reactivestreams") return name.startsWith("org.reactivestreams")
|| name.startsWith("reactor.") || name.startsWith("reactor.");
|| name.startsWith("java")
|| name.startsWith("com.sun");
} }
private String discoverFunctionClassName(FunctionProperties functionProperties) { private String discoverFunctionClassName(FunctionProperties functionProperties) {