Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -258,7 +258,8 @@ public void loadServerInfo() {
if (tmpDbUser != null && !tmpDbUser.isEmpty()) {
this.dbUser = tmpDbUser;
}
this.configuration.put(ClientConfigProperties.SERVER_TIMEZONE.getKey(), reader.getString("timezone"));
this.configuration.put(ClientConfigProperties.SERVER_TIMEZONE.getKey(),
ClientConfigProperties.SERVER_TIMEZONE.parseValue(reader.getString("timezone")));
serverVersion = reader.getString("version");
}
}
Expand Down
16 changes: 16 additions & 0 deletions client-v2/src/test/java/com/clickhouse/client/ClientTests.java
Original file line number Diff line number Diff line change
Expand Up @@ -322,6 +322,22 @@ public void testLoadingServerContext() throws Exception {
}
}

@Test(groups = {"integration"})
public void testServerTimeZoneAfterLoadingServerInfo() throws Exception {
try (Client client = newClient().build()) {
// Before loadServerInfo() the client returns the configured value.
Assert.assertEquals(client.getServerTimeZone(), "UTC");

String expected = client.queryAll("SELECT timezone()").get(0).getString(1);
client.loadServerInfo();
Assert.assertEquals(client.getServerTimeZone(), expected);
}

try (Client client = newClient().setServerTimeZone("Europe/Berlin").build()) {
Assert.assertEquals(client.getServerTimeZone(), "Europe/Berlin");
}
}

@Test(groups = {"integration"})
public void testDisableNative() {
try (Client client = newClient().disableNativeCompression(true).build()) {
Expand Down
4 changes: 4 additions & 0 deletions history/latest/3357.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
- **[client-v2]** Fixed `Client#getServerTimeZone()`, which failed with `ClassCastException` (`String` cannot be cast
to `TimeZone`) after a call to `Client#loadServerInfo()`. `loadServerInfo()` now stores the server time zone as a
`TimeZone`, the same type as the parsed client configuration.
(https://github.com/ClickHouse/clickhouse-java/issues/3357)
Loading