While debugging deadlock in our application, I found that spring-boot's LaunchedClassLoader is not registered as parallel capable class loader.
Even though LaunchedClassLoader register itself as parallel capable, ClassLoader only accepts registerAsParallelCapable if the super class is also parallel capable.
https://github.com/openjdk/jdk/blob/f174bbd3baf351ae9248b70454b3bc5a89acd7c6/src/java.base/share/classes/java/lang/ClassLoader.java#L270-L284
static boolean register(Class<? extends ClassLoader> c) {
synchronized (loaderTypes) {
if (loaderTypes.contains(c.getSuperclass())) {
// register the class loader as parallel capable
// if and only if all of its super classes are.
// Note: given current classloading sequence, if
// the immediate super class is parallel capable,
// all the super classes higher up must be too.
loaderTypes.add(c);
return true;
} else {
return false;
}
}
Looking at this issue (https://github.com/spring-projects/spring-boot/issues/7333), it seems LaunchedClassLoader is parallel capable. So this PR registers LaunchedClassLoader's parent class, JarUrlClassLoader as parallel capable.
Comment From: pivotal-cla
@Rajin9601 Please sign the Contributor License Agreement!
Click here to manually synchronize the status of this Pull Request.
See the FAQ for frequently asked questions.
Comment From: pivotal-cla
@Rajin9601 Thank you for signing the Contributor License Agreement!
Comment From: wilkinsona
Thanks very much, @Rajin9601.
This looks like a regression in 3.2 to me where JarUrlClassLoader was introduced as the super-class of LaunchedURLClassLoader. In 3.2 with the classic loader or in 3.1, LaunchedURLClasssLoader extends URLClassLoader and will be parallel capable.
Comment From: wilkinsona
Thanks very much, @Rajin9601 .