Skip to content

fix(client-v2): keep server time zone as TimeZone in loadServerInfo - #3362

Merged
chernser merged 1 commit into
ClickHouse:mainfrom
rohan4naik:fix/load-server-info-timezone-3357
Nov 17, 2026
Merged

chernser merged 1 commit into
ClickHouse:mainfrom
rohan4naik:fix/load-server-info-timezone-3357

Conversation

@rohan4naik

@rohan4naik rohan4naik commented Nov 17, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Client.getServerTimeZone() threw ClassCastException (String cannot be cast to TimeZone) on every call after Client.loadServerInfo().

Cause. The parsed client configuration keeps server_time_zone as a java.util.TimeZone, and getServerTimeZone() casts the value to TimeZone. loadServerInfo() wrote the timezone() result to the same key as a String.

Fix. loadServerInfo() now stores the value through ClientConfigProperties.SERVER_TIMEZONE.parseValue(...), as the issue suggests. This is the conversion the client already uses when it parses its configuration, so both write paths keep the same type. I preferred this to making getServerTimeZone() accept both types, because other readers of this key (QuerySettings, QueryResponse) also cast to TimeZone.

Tests. Added ClientTests#testServerTimeZoneAfterLoadingServerInfo:

  • before loadServerInfo(), getServerTimeZone() returns the configured default (UTC);
  • after loadServerInfo(), it returns the server's timezone();
  • contrast case: a value from setServerTimeZone(...) is returned unchanged.

I ran it against a local ClickHouse 26.11 server configured with Asia/Tokyo (TEST_CLICKHOUSE_CONTAINER=none), JDK 17. Without the fix the test fails with the ClassCastException from the issue; with the fix it passes and returns Asia/Tokyo. mvn -pl client-v2 test -Dtest='ClientTests,ParameterizedQueryTest,SettingsTests' also passes locally. I did not run the full integration suite or the Docker-based setup locally.

Closes #3357

Checklist

This change was prepared with AI assistance; I reproduced the bug and ran the tests listed above.

🤖 Generated with Claude Code


Note

Low Risk
Single-line type-alignment fix in server-info loading with regression tests; no auth or data-path changes.

Overview
Fixes Client#getServerTimeZone() throwing ClassCastException after loadServerInfo() by no longer storing the server's timezone() result as a raw String in client configuration.

loadServerInfo() now writes the server time zone through ClientConfigProperties.SERVER_TIMEZONE.parseValue(...), matching the TimeZone type used when configuration is parsed and what getServerTimeZone() (and other readers) expect.

An integration test verifies default UTC, post-load alignment with the server zone, and unchanged behavior when setServerTimeZone(...) is configured. A changelog entry is added for issue #3357.

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

Client.loadServerInfo() stored the server time zone as a String, but
Client.getServerTimeZone() casts the configuration value to TimeZone.
Every getServerTimeZone() call after loadServerInfo() failed with
ClassCastException.

Store the value through ClientConfigProperties.SERVER_TIMEZONE.parseValue(),
the same conversion that the client uses when it parses its configuration.

Closes ClickHouse#3357
@rohan4naik
rohan4naik requested review from a team and mzitnik as code owners November 17, 2026 09:17
Copilot AI balanced review requested due to automatic review settings November 17, 2026 09:17

Copilot AI 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.

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.

@chernser
chernser merged commit 63abcd1 into ClickHouse:main Nov 17, 2026
43 of 45 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.

[client-v2] Client.getServerTimeZone() throws ClassCastException after Client.loadServerInfo()

3 participants