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: Make using Java's ServiceLoader optional on Database.connect() #2293

Merged
merged 2 commits into from
Nov 26, 2024

Conversation

makeevrserg
Copy link
Contributor

@makeevrserg makeevrserg commented Nov 1, 2024

Description

Summary of the change: Make using ServiceLoader for DatabaseConnectionAutoRegistrationnot optional

Detailed description:

  • What: connectionInstanceImpl doesn't need to be created using java ServiceLoader.
  • Why: In some cases with different loaders it may throw exception even if existing interface implementation is present. Also this may improve stability as reflection will not be required during connection.
  • How: The connectionInstanceImpl is now lazy-loaded so even if ServiceLoader doesn't have required service, code block will not crash. Every connect method have now connectionAutoRegistration as a parameter instead of previous private-service-loaded
  • This also relevant to older issues on github, which is marked as closed, but still could be reproduced located below
  • This also may be a small step in migration to KMP if it's planned.

Type of Change

Please mark the relevant options with an "X":

  • Bug fix
  • New feature
  • Documentation update

Updates/remove existing public API methods:

  • Is breaking change

Affected databases:

  • MariaDB
  • Mysql5
  • Mysql8
  • Oracle
  • Postgres
  • SqlServer
  • H2
  • SQLite

Checklist

  • Unit tests are in place
  • The build is green (including the Detekt check)
  • All public methods affected by my PR has up to date API docs
  • Documentation for my change is up to date

Related Issues

@makeevrserg makeevrserg changed the title fix class loader fix: make using java's ServiceLoader optional Nov 1, 2024
@makeevrserg makeevrserg force-pushed the fix-class-loader branch 2 times, most recently from 703e196 to 6b887a8 Compare November 1, 2024 10:35
@bog-walk bog-walk self-assigned this Nov 1, 2024
Copy link
Member

@bog-walk bog-walk left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for working on this PR @makeevrserg !
Please consider rebasing from main and addressing the suggested changes.

gradle.properties Outdated Show resolved Hide resolved
@bog-walk bog-walk changed the title fix: make using java's ServiceLoader optional fix: Make using Java's ServiceLoader optional on Database.connect() Nov 26, 2024
@bog-walk bog-walk linked an issue Nov 26, 2024 that may be closed by this pull request
@bog-walk bog-walk requested a review from e5l November 26, 2024 01:16
@makeevrserg makeevrserg marked this pull request as draft November 26, 2024 08:02
@makeevrserg makeevrserg force-pushed the fix-class-loader branch 3 times, most recently from 17616b2 to b23b37b Compare November 26, 2024 08:20
@makeevrserg makeevrserg marked this pull request as ready for review November 26, 2024 08:56
@makeevrserg makeevrserg requested a review from bog-walk November 26, 2024 08:57
Copy link
Member

@e5l e5l left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks for the contribution, lgtm!

@bog-walk bog-walk merged commit a6fed1d into JetBrains:main Nov 26, 2024
3 checks passed
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.

Issue with relocation using Shadow Jar
3 participants