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

use ServiceLoader.load with the current classloader instead of the context classloader #306

Merged
merged 1 commit into from
May 12, 2021

Conversation

jonenst
Copy link
Contributor

@jonenst jonenst commented May 11, 2021

Please check if the PR fulfills these requirements (please use '[x]' to check the checkboxes, or submit the PR and then click the checkboxes)

  • The commit message follows our guidelines
  • Tests for the changes have been added (for bug fixes / features)
  • Docs have been added / updated (for bug fixes / features)

Does this PR already have an issue describing the problem ? If so, link to this issue using '#XXX' and skip the rest
powsybl/powsybl-core#1727

…ntext classloader

The context classloader can be the wrong one (and ServiceLoader.load returns an empty list)
when you are calling ServiceLoader.load in the ForkJoinPool.commonPool() (or any other thread pool)
and you have your classes in another classloader than the AppClassLoader (=system classloader).
This is the case when using a springboot fat jar, or when deploying the code in a war in an application
server, or when using mvn exec:java

Signed-off-by: Jon Harper <jon.harper87@gmail.com>
@jonenst jonenst force-pushed the fixserviceloaderclassloader branch from d63c748 to 44616a4 Compare May 11, 2021 06:48
@sonarqubecloud
Copy link

Kudos, SonarCloud Quality Gate passed!

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 0 Code Smells

66.7% 66.7% Coverage
0.0% 0.0% Duplication

@jonenst jonenst requested a review from flo-dup May 12, 2021 10:03
@geofjamg geofjamg merged commit ca793a8 into master May 12, 2021
@geofjamg geofjamg deleted the fixserviceloaderclassloader branch May 12, 2021 20:00
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