Skip to content

fix(jdbc): preserve detected frameworks on client info updates - #3315

Merged
chernser merged 5 commits into
ClickHouse:mainfrom
pcbeingused333:fix/jdbc-frameworks-3219
Nov 17, 2026
Merged

chernser merged 5 commits into
ClickHouse:mainfrom
pcbeingused333:fix/jdbc-frameworks-3219

Conversation

@pcbeingused333

@pcbeingused333 pcbeingused333 commented Nov 9, 2026 •

Copy link
Copy Markdown
Contributor

Fixes #3219

Summary

ConnectionImpl and JdbcConfiguration.updateUserClient built the JDBC client name separately, and the update path omitted the framework group. Use one JdbcConfiguration.buildClientName helper for connection creation and updates. Keep the detected frameworks when Connection.setClientInfo("ApplicationName", ...) updates or clears the application name. Respect disabled framework detection. Null and empty application names no longer add leading whitespace. An empty client_name (or legacy product_name) at connection creation also no longer adds a leading space.

The existing framework group format is unchanged. This does not change public API signatures, property defaults, or JDBC value types. It restores the documented framework information after a client info update. Update the feature list and add a release note.

Tests

Add nine parameterized cases for nonempty, empty, and null application names with detected frameworks, no detected frameworks, and disabled detection. The tests use a real client and inspect its active configuration, rather than its initial configuration snapshot. Restore the framework detection cache after each case.

Run ClientNameTest and JdbcConfigurationTest in Maven with Java 17. On main: 114 tests, 7 failures, 0 errors. With the fix: 114 tests, 0 failures, 0 errors.

Checklist

AI assistance: OpenAI Codex generated the patch and regression tests.


Note

Low Risk
Low risk: observable HTTP User-Agent formatting and client-name whitespace fix only; no API or query/data-path changes.

Overview
JDBC User-Agent behavior now keeps auto-detected frameworks (e.g. Spark) when Connection.setClientInfo("ApplicationName", ...) changes or clears the app name. Frameworks are emitted as an fw key in the client_id_metadata comment group instead of a second parenthesized segment on the client name, and a user-provided client_id_metadata fw overrides detection.

Client naming is unified through JdbcConfiguration.buildClientName() for connect and client-info updates so the application prefix and driver suffix stay consistent. Null, empty, or unset application names no longer introduce leading whitespace in the header prefix.

Docs and a changelog entry describe the new header shape; integration tests cover framework presence with varied app names, disabled detection, and custom fw metadata.

Reviewed by Cursor Bugbot for commit 2201209. Bugbot is set up for automated code reviews on this repo. Configure here.

@chernser chernser left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Thank you for contribution!

Please address the comments and
add test to verify that user client string always in the format:

<app_name>/<app_version> <client_name>/<client_version> (<comment>; <key1>: <value1>; <key2>: <value2>)

Not parentheses in the middle (this is our format across all clients to make things clear)

Thanks!

@pcbeingused333

Copy link
Copy Markdown
Contributor Author

Thanks for the review. Pushed 08f64da and e778908 on top of the earlier commits:

  • Detected frameworks no longer go into the client name. They are added to the client metadata as an fw entry, so the header keeps the format <app>/<ver> jdbc-v2/<ver> clickhouse-java-v2/<ver> (fw:apache.spark; lv:...; os:...; hc:...) with one parenthesis group. A fw entry set by the user in client_id_metadata wins. The metadata survives updateClientName, so setClientInfo("ApplicationName", ...) keeps the frameworks.
  • Removed the standalone ClientNameTest. The test is now ConnectionTest#testDetectedFrameworksInUserAgent (integration group, next to testClientMetadataInUserAgent): it reads http_user_agent from system.query_log and checks the full format with a regex (single parenthesis group, with and without app name, detected frameworks, a user fw entry winning, detection disabled). No reflection on private fields.
  • Updated docs and the history entry.

Your template shows a free <comment> item before the key/value pairs. This patch uses a keyed fw entry so it can be overridden through client_id_metadata. If you prefer the frameworks as the plain comment item, that is a small change.

Disclosure: this change was prepared with an AI coding assistant and reviewed before posting.

@security-ai-gate-reviewer

security-ai-gate-reviewer Bot commented Nov 12, 2026 •

Copy link
Copy Markdown

AI review gate — the gate never ran on this head

The org-required gate workflow has no run on e778908d47be: this pull request was open before the repository was enrolled, and GitHub starts that workflow only on opened, synchronize and reopened. Nothing here can merge until it runs.

What to do: a maintainer runs rollout kick-gate --repo ClickHouse/clickhouse-java --pr 3315 --apply from infra/github/conformance in security-integrations (dry run without --apply), or closes and reopens this pull request (auto-merge is turned off by the close; re-enable it after).

History (latest 5 heads, newest first)

  • e778908d47be gate never ran — needs a kick

@pcbeingused333

Copy link
Copy Markdown
Contributor Author

Hi @chernser, I've addressed the review feedback. Could you take another look when you have a moment?

@chernser

Copy link
Copy Markdown
Contributor

Thank you @pcbeingused333 !

I've approved. Will merge a bit later.

@ccoltx ccoltx closed this Nov 17, 2026
@ccoltx ccoltx reopened this Nov 17, 2026
@ccoltx
ccoltx requested a review from a team as a code owner November 17, 2026 07:15
@github-actions

Copy link
Copy Markdown

AI review gate — Human approval in place of AI review

Approved on the head commit by chernser (write access, not the author), standing in for the AI review:

  • Cursor Bugbot is still reviewing this commit.

What to do:

  • Nothing to do yet if the review is running. The gate turns green when it finishes clean.
  • No review showing up? Post bugbot run as a new top-level PR comment. If that does nothing, Bugbot is probably not enabled for this repository: ask a repository administrator.

Evaluated at 22012093. This required workflow does not re-run on its own once the AI review later concludes — check the Cursor Bugbot check on this commit directly for its current state.

@chernser
chernser merged commit 57261ad into ClickHouse:main Nov 17, 2026
2 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.

[jdbc-v2] setClientInfo(ApplicationName) removes the detected frameworks from the User-Agent

3 participants