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

Allow configuring explicit driver class loader #1825

Closed
wants to merge 1 commit into from

Conversation

timja
Copy link

@timja timja commented Aug 10, 2021

For more controlled classloading than was added in #881

I'm trying to use this to replace commons-dbcp2 in Jenkins, and neither of the classloading options that are available here work (docs: https://www.jenkins.io/doc/developer/plugin-development/dependencies-and-class-loading/)

Similar issue:
FasterXML/jackson-dataformat-xml#483 (comment)

I've tested this in Jenkins and it works.

@codecov
Copy link

codecov bot commented Aug 10, 2021

Codecov Report

Attention: Patch coverage is 18.42105% with 31 lines in your changes missing coverage. Please review.

Project coverage is 70.26%. Comparing base (ed2da5f) to head (d78837f).
Report is 86 commits behind head on dev.

Files with missing lines Patch % Lines
.../java/com/zaxxer/hikari/util/DriverDataSource.java 0.00% 21 Missing ⚠️
src/main/java/com/zaxxer/hikari/HikariConfig.java 37.50% 8 Missing and 2 partials ⚠️
Additional details and impacted files

Impacted file tree graph

@@             Coverage Diff              @@
##                dev    #1825      +/-   ##
============================================
- Coverage     70.75%   70.26%   -0.50%     
- Complexity      575      576       +1     
============================================
  Files            26       26              
  Lines          2171     2189      +18     
  Branches        311      315       +4     
============================================
+ Hits           1536     1538       +2     
- Misses          484      498      +14     
- Partials        151      153       +2     
Files with missing lines Coverage Δ
src/main/java/com/zaxxer/hikari/pool/PoolBase.java 72.16% <100.00%> (ø)
src/main/java/com/zaxxer/hikari/HikariConfig.java 75.95% <37.50%> (-1.58%) ⬇️
.../java/com/zaxxer/hikari/util/DriverDataSource.java 44.73% <0.00%> (-5.27%) ⬇️

... and 2 files with indirect coverage changes


Continue to review full report in Codecov by Sentry.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update ed2da5f...d78837f. Read the comment docs.

@brettwooldridge
Copy link
Owner

I don't like this change. First, any change to class signatures requires a major revision increment. Second, the usual pattern for adapting to a classloading framework is to switch the context classloader and then switch back.

var originalLoader = Thread.currentThread().getContextClassLoader();
try {
   Thread.currentThread().setContextClassLoader(myClassLoader);

   HikariConfig config = new HikariConfig();
   // setup
   return new HikariDataSource(config);
} finally {
   Thread.currentThread().setContextClassLoader(originalLoader);
}

@timja timja deleted the explicit-classloader branch November 2, 2024 09:08
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.

2 participants