Skip to content

fix(clickhouse-client): load services from client module#2941

Open
014-code wants to merge 1 commit into
ClickHouse:mainfrom
014-code:fix/2669-jpms-service-loader
Open

fix(clickhouse-client): load services from client module#2941
014-code wants to merge 1 commit into
ClickHouse:mainfrom
014-code:fix/2669-jpms-service-loader

Conversation

@014-code

Copy link
Copy Markdown
Contributor

Summary

Fix JPMS/module-path service loading for ClickHouseRequestManager.

Fixes #2669.

Problem

When applications run ClickHouse Java modules on the module path, loading
ClickHouseRequestManager can fail with:

java.util.ServiceConfigurationError: com.clickhouse.client.ClickHouseRequestManager: module com.clickhouse.data does not declare uses

The failure happens because ClickHouseRequestManager was loaded through
ClickHouseUtils.getService(...), so the actual ServiceLoader.load(...)
caller was in the com.clickhouse.data module. com.clickhouse.data cannot
declare uses com.clickhouse.client.ClickHouseRequestManager without creating
a reverse dependency on com.clickhouse.client.

Changes

  • Load ClickHouseRequestManager providers directly from the
    com.clickhouse.client module.
  • Load ClickHouseDnsResolver providers directly from the
    com.clickhouse.client module for the same JPMS reason.
  • Add uses com.clickhouse.client.ClickHouseRequestManager to the Java 9 and
    Java 11 module descriptors.
  • Add focused test coverage for the service fallback and module descriptor
    contract.
  • Update CHANGELOG.md.

Compatibility

No public API changes.

Default behavior is preserved: when no custom provider is found, the client
falls back to the built-in ClickHouseRequestManager and ClickHouseDnsResolver
implementations. The change only moves service loading to the module that owns
and declares the service types.

Testing

  • git diff --check
  • mvn -t C:\tmp\clickhouse-java-toolchains.xml -Dj8 -pl clickhouse-client -am -Dtest=com.clickhouse.client.ClickHouseClientTest -Dsurefire.failIfNoSpecifiedTests=false test

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Cursor Bugbot has reviewed your changes using high effort and found 1 potential issue.

Fix All in Cursor

Reviewed by Cursor Bugbot for commit 1f56b10. Configure here.

Comment thread clickhouse-client/src/test/java/com/clickhouse/client/ClickHouseClientTest.java Outdated
Load ClickHouseRequestManager and ClickHouseDnsResolver providers from the com.clickhouse.client module instead of delegating through ClickHouseUtils in com.clickhouse.data. This keeps JPMS ServiceLoader uses checks aligned with the module that owns the service types.

Add the missing ClickHouseRequestManager uses directives to the Java 9 and Java 11 module descriptors and cover the fallback/module descriptor contract in ClickHouseClientTest.

Fixes ClickHouse#2669
@014-code
014-code force-pushed the fix/2669-jpms-service-loader branch from 1f56b10 to fd2cf5d Compare July 21, 2026 12:07
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.

com.clickhouse.client.ClickHouseRequestManager: module com.clickhouse.data does not declare uses #1493

1 participant