Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: getClassLoader() may return null #15230

Open
wants to merge 1 commit into
base: 2.7.x
Choose a base branch
from
Open

Conversation

fayfox
Copy link

@fayfox fayfox commented Mar 11, 2025

In the Java 8 + WAR + Tomcat runtime environment, when using CompletableFuture.runAsync() (which runs in ForkJoinPool), Thread.currentThread().getContextClassLoader() may return null.

Meanwhile, SerializerFactory#getClassFactory only creates a ClassFactory instance on its first invocation. If the first Dubbo call happens to be executed in ForkJoinPool, ClassFactory._loader will be initialized as null and will remain null permanently. As a result, all subsequent Dubbo calls will fail during deserialization (objects will be converted to HashMap).

Therefore, if classLoader is null at this point, it is better to throw an exception immediately to prevent ClassFactory from being initialized incorrectly.

In the Java 8 + WAR + Tomcat runtime environment, when using CompletableFuture.runAsync() (which runs in ForkJoinPool), Thread.currentThread().getContextClassLoader() may return null.

Meanwhile, SerializerFactory#getClassFactory only creates a ClassFactory instance on its first invocation. If the first Dubbo call happens to be executed in ForkJoinPool, ClassFactory._loader will be initialized as null and will remain null permanently. As a result, all subsequent Dubbo calls will fail during deserialization (objects will be converted to HashMap).

Therefore, if classLoader is null at this point, it is better to throw an exception immediately to prevent ClassFactory from being initialized incorrectly.
@AlbumenJ
Copy link
Member

2.7.x has been EOL. In this case, hessian should support null classloader.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants