-
Notifications
You must be signed in to change notification settings - Fork 3.4k
HBASE-25338 Use ClassLoader of current class instead of thread context ClassLoader #6918
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
Conversation
|
Thankfully there is a workaround for this issue. By setting extra providers option to built-in providers, you may bypass the issue and load the built-in providers. For example: See here for more context. |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
|
Please add a new commit which modifies pom.xml so we can trigger tests for the whole project. We can remove it while merging. Thanks. |
You mean the root |
|
Just in case, also attaching the test result of my test project mentioned above to be sure that the edit resolves the issue. I made a custom build of hbase-client from branch-2.5, using hadoop 2, PR applied. Image 1 shows that the custom build resolves the problem.
|
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
|
Seems OK, please revert the commit which modifies pom.xml, I will merge it later. Thanks @challenger71498 |
This reverts commit 8663c3a.
|
@Apache9 Will this PR be backported to 2.x? Since the master branch is for 4.0 (which hasn’t been released yet), and I am currently using version 2.6.2, it would be great if this PR could be backported. |
…t ClassLoader (#6918) Signed-off-by: Duo Zhang <[email protected]> (cherry picked from commit bd30367)
…t ClassLoader (#6918) Signed-off-by: Duo Zhang <[email protected]> (cherry picked from commit bd30367)
…t ClassLoader (#6918) Signed-off-by: Duo Zhang <[email protected]> (cherry picked from commit bd30367)
…t ClassLoader (#6918) Signed-off-by: Duo Zhang <[email protected]> (cherry picked from commit bd30367)
|
@challenger71498 Could you please reply on the jira so I can assign the jira to you? I've cherry-picked the patch to all active branches. Thanks for contributing! |
|
🎊 +1 overall
This message was automatically generated. |
|
Sure, I just requested a Jira account by self-service portal. I will leave a comment after getting one :) |
|
💔 -1 overall
This message was automatically generated. |
…t ClassLoader (apache#6918) Signed-off-by: Duo Zhang <[email protected]> (cherry picked from commit bd30367)
…t ClassLoader (apache#6918) Signed-off-by: Duo Zhang <[email protected]> (cherry picked from commit bd30367)


Details
When the
ServiceLoader::loadmethod is invoked with a single argument, it uses the contextClassLoaderof current thread(by callingThread.currentThread.getContextClassLoader()). (For definition, see here.)Under normal circumstances, this does not cause issues. But there is a problem if you try to:
URLClassLoader::loadClass)hbase-client)In my case, I encountered this problem while developing JDBC wrapper for hbase-shell.
If you load the class from the jar file, the
ClassLoaderof current thread is normally the class loader used to load the parent application.ClassLoaderis not adaquate toServiceLoaderat theSaslClientAuthenticationProviders.ServiceLoaderwith the "parent"ClassLoadercould not access the service info of the jar file(META-INF/services).I also attached the full stacktrace of the exception just in case.
Stacktrace
I could reproduce this issue with the repository which I made by myself in here. You could also look into it for more information.
Suggestion
As @AbilashR mentioned at the issue, this can be fixed by adding ClassLoader of current class explicitly to the parameter.
I have run the test locally and had no issues. Please let me know if there are more tests I should run.
I also tried to add a test case for this, but gave up since reproducing the issue is quite complicated.
Any opinions & suggestions are appriciated. Also, I don't have much experiences in Java, so feel free to make any corrections.
Thank you :)