Skip to content

Commit 69cc780

Browse files
authored
Merge branch 'v0.10.0' into 07/06/26/binary_string_support
2 parents 34a10d6 + 035d69d commit 69cc780

16 files changed

Lines changed: 1505 additions & 218 deletions

File tree

CHANGELOG.md

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,17 @@
4848

4949
- **[client-v2]** The public `ClickHouseBinaryFormatWriter` interface gained two methods, `setString(String, byte[])` and `setString(int, byte[])`, for writing raw `String`/`FixedString` bytes. Code that only *uses* the interface is unaffected, but any third party that *implements* `ClickHouseBinaryFormatWriter` directly is source- and binary-incompatible until it adds these methods (recompiling against the new version is required; otherwise an `AbstractMethodError` can occur at runtime).
5050

51+
- **[client-v2]** HTTP `503 Service Unavailable` responses are now surfaced as a connection-style failure (
52+
`java.net.ConnectException`) and are retried by default. Previously a `503` was treated as a server error (
53+
`ServerException`) and fell under the `ServerRetryable` fault cause. It has been moved to the `ConnectTimeout` fault
54+
cause category so that connectivity/availability failures are handled uniformly with other connection errors. Callers
55+
that specifically excluded `ServerRetryable` to avoid retrying `503` should now adjust their
56+
`client_retry_on_failures` configuration to exclude `ConnectTimeout` instead.
57+
58+
- **[client-v2]** Unexpected/unknown HTTP status codes (those the client cannot interpret as a ClickHouse response) now
59+
throw a `ClientException` instead of a `ServerException`. Since the client cannot meaningfully handle these responses,
60+
they are reported as a client-side error rather than being attributed to the server.
61+
5162
### New Features
5263

5364
- **[jdbc-v2, client-v2]** Implemented SSL modes configuration. Now it is possible to set `ssl_mode` to `DISABLED`,
@@ -97,7 +108,7 @@
97108
to be returned in their native form regardless of the user-supplied map. Existing maps keyed only by JDBC `SQLType`
98109
names continue to work unchanged. (https://github.com/ClickHouse/clickhouse-java/pull/2865)
99110

100-
- **[jdbc-v2]** Added support of custom mapping for JDBC types. Mainly used in cases when big integers should be
111+
- **[jdbc-v2]** Added support of custom mapping for JDBC types. Mainly used in cases when big integers should be
101112
presented as string. Use `DriverProperties.JDBC_TYPE_MAPPINGS` (`jdbc_type_mappings`) and set needed type mapping
102113
as `key=value[,]` list (For example, `Int32=Long,UInt64=String`). Deprecation notice: V1 property `typeMappings` is
103114
supported but will be removed. Please migrate to the new property.
@@ -115,6 +126,12 @@
115126
expected to carry large/binary strings. On the JDBC side, `ResultSet#getBinaryStream(int)` and
116127
`ResultSet#getBinaryStream(String)` are now implemented (previously unsupported) and, together with `getBytes(...)`,
117128
return the raw column bytes.
129+
130+
- **[client-v2]** Added `Client#cancelTransportRequest(String queryId)` to cancel an in-flight request that has not yet
131+
received a response from the server, identified by the query id supplied in the operation settings. This aborts the
132+
request on the client side (cancels the underlying IO operation) but does **not** issue a `KILL QUERY` on the server,
133+
so a query that already started executing may continue to run server-side. It is recommended to use operation timeout
134+
settings where possible; this API is intended for explicitly aborting a request from the client.
118135

119136
### Improvements
120137

client-v2/src/main/java/com/clickhouse/client/api/Client.java

Lines changed: 153 additions & 121 deletions
Large diffs are not rendered by default.

client-v2/src/main/java/com/clickhouse/client/api/http/ClickHouseHttpProto.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,12 @@ public class ClickHouseHttpProto {
8484
*/
8585
public static final String QPARAM_QUERY_STMT = "query";
8686

87+
public static final String QPARAM_ENABLE_HTTP_COMPRESSION = "enable_http_compression";
88+
89+
public static final String QPARAM_COMPRESS = "compress";
90+
91+
public static final String QPARAM_DECOMPRESS = "decompress";
92+
8793
public static final int DEFAULT_HTTP_PORT = 8123;
8894

8995
public static final int DEFAULT_HTTPS_PORT = 8443;

client-v2/src/main/java/com/clickhouse/client/api/insert/InsertResponse.java

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,21 +3,17 @@
33
import com.clickhouse.client.api.http.ClickHouseHttpProto;
44
import com.clickhouse.client.api.metrics.OperationMetrics;
55
import com.clickhouse.client.api.metrics.ServerMetrics;
6+
import com.clickhouse.client.api.transport.internal.TransportResponse;
67

7-
import java.util.Collections;
88
import java.util.Map;
99

1010
public class InsertResponse implements AutoCloseable {
1111
private OperationMetrics operationMetrics;
1212
private final Map<String, String> responseHeaders;
1313

14-
public InsertResponse(OperationMetrics metrics) {
15-
this(metrics, Collections.emptyMap());
16-
}
17-
18-
public InsertResponse(OperationMetrics metrics, Map<String, String> responseHeaders) {
14+
public InsertResponse(TransportResponse transportResponse, OperationMetrics metrics) {
1915
this.operationMetrics = metrics;
20-
this.responseHeaders = responseHeaders;
16+
this.responseHeaders = transportResponse.getHeaders();
2117
}
2218

2319
@Override

client-v2/src/main/java/com/clickhouse/client/api/internal/ClientUtils.java

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
package com.clickhouse.client.api.internal;
22

3+
import org.slf4j.Logger;
4+
5+
import java.io.Closeable;
6+
37
/**
48
* Class containing utility methods used across the client.
59
*/
@@ -14,4 +18,14 @@ public static boolean isNotBlank(String str) {
1418
public static boolean isBlank(String str) {
1519
return str == null || str.trim().isEmpty();
1620
}
21+
22+
public static void quietClose(Closeable closeable, Logger log) {
23+
if (closeable != null) {
24+
try {
25+
closeable.close();
26+
} catch (Exception e) {
27+
log.warn("Failed to close object " + closeable, e);
28+
}
29+
}
30+
}
1731
}

0 commit comments

Comments
 (0)