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
[BACKPORT] Fix constructor cache in ClassLoaderUtil #13511
[BACKPORT] Fix constructor cache in ClassLoaderUtil #13511
Conversation
@@ -102,13 +102,13 @@ private ClassLoaderUtil() { | |||
return newInstance(klass, classLoader, className); | |||
} | |||
|
|||
public static <T> T newInstance(Class<T> klass, ClassLoader classLoader, String className) throws Exception { | |||
public static <T> T newInstance(Class<T> klass, ClassLoader unused, String className) throws Exception { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
would it be ok to remove this parameter altogether?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This effectively disable caching in the case of delegating classloaders.
The code should populate the constructor cache with the classloader which was used to load the class. because that's what the cache lookup code is using.
however you are now populating the cache with a classloader which was used to define the class.
- The constructor will be cached with the class loader (CL) that returned the class. Fixes hazelcast#13509 - The same CL could be queried multiple times (performance problem) - the thread's context CL wasn't used at all for `com.hazelcast` package. This problem partly remains, see comment in code. - add documentation - make the oddly-defined 3-arg `newInstance` method private
ee1cdfb
to
7d18f7d
Compare
Closing in favour of #13679 |
Fixes #13509
Backport of #13512