Skip to content

Commit 599ccd2

Browse files
committed
Merge branch 'main' into feat_draft_transport_skeleton
2 parents 7d4d4d9 + f499762 commit 599ccd2

File tree

15 files changed

+72
-37
lines changed

15 files changed

+72
-37
lines changed

.github/workflows/analysis.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ on:
2828
required: false
2929

3030
env:
31-
PREFERRED_LTS_VERSION: "23.3"
31+
PREFERRED_LTS_VERSION: "24.3"
3232

3333
jobs:
3434
static:

.github/workflows/build-template.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ concurrency:
77
cancel-in-progress: true
88

99
env:
10-
PREFERRED_LTS_VERSION: "23.3"
10+
PREFERRED_LTS_VERSION: "24.3"
1111
CLICKHOUSE_TEST_VERSIONS: "[]"
1212

1313
jobs:

.github/workflows/build.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ concurrency:
3232
cancel-in-progress: true
3333

3434
env:
35-
PREFERRED_LTS_VERSION: "23.7"
35+
PREFERRED_LTS_VERSION: "24.3"
3636

3737
jobs:
3838
compile:
@@ -179,7 +179,7 @@ jobs:
179179
matrix:
180180
# most recent LTS releases as well as latest stable builds
181181
# https://github.com/ClickHouse/ClickHouse/pulls?q=is%3Aopen+is%3Apr+label%3Arelease
182-
clickhouse: ["22.8", "23.3", "23.7", "latest"]
182+
clickhouse: ["23.8", "24.3", "24.6", "latest"]
183183
fail-fast: false
184184
timeout-minutes: 15
185185
name: Java client + CH ${{ matrix.clickhouse }}
@@ -234,7 +234,7 @@ jobs:
234234
needs: compile
235235
strategy:
236236
matrix:
237-
clickhouse: ["22.8", "23.3", "23.7", "latest"]
237+
clickhouse: ["23.8", "24.3", "24.6", "latest"]
238238
# here http, http_client and apache_http_client represent different value of http_connection_provider
239239
protocol: ["http", "http_client", "apache_http_client", "grpc"]
240240
fail-fast: false
@@ -293,7 +293,7 @@ jobs:
293293
needs: compile
294294
strategy:
295295
matrix:
296-
clickhouse: ["22.8", "23.3", "23.7", "latest"]
296+
clickhouse: ["23.8", "24.3", "24.6", "latest"]
297297
# grpc is not fully supported, and http_client and apache_http_client do not work in CI environment(due to limited threads?)
298298
protocol: ["http"]
299299
r2dbc: ["1.0.0.RELEASE", "0.9.1.RELEASE"]

.github/workflows/nightly.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ on:
1212

1313
env:
1414
CHC_BRANCH: "main"
15-
CHC_VERSION: "0.6.2"
15+
CHC_VERSION: "0.6.3"
1616

1717
jobs:
1818
nightly:

.github/workflows/release.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ on:
66
version:
77
description: "Release version"
88
required: true
9-
default: "0.6.2-SNAPSHOT"
9+
default: "0.6.3-SNAPSHOT"
1010

1111
jobs:
1212
release:

CHANGELOG.md

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,27 @@
1-
## Latest
1+
## Latest
2+
3+
## 0.6.3
4+
5+
### Important Changes
6+
- [Client-V1] Changed how `User-Agent` string is generated. Now `ClickHouse-JavaClient` portion is appended in all cases.
7+
It is still possible to set custom product name that will be the first part in `User-Agent` value.
8+
(https://github.com/ClickHouse/clickhouse-java/issues/1698)
9+
10+
### New Features
11+
- [Client-V1/Apache HTTP] Retry on NoHttpResponseException in Apache HTTP client.
12+
Should be used with causes because it is not always possible to resend request body.
13+
Behaviour is controlled by `com.clickhouse.client.http.config.ClickHouseHttpOption#AHC_RETRY_ON_FAILURE`.
14+
Works only for Apache HTTP client because based on its specific behavior(https://github.com/ClickHouse/clickhouse-java/pull/1721)
15+
- [Client-V1/Apache HTTP] Connection validation before sending request.
16+
Behaviour is controlled by `com.clickhouse.client.http.config.ClickHouseHttpOption#AHC_VALIDATE_AFTER_INACTIVITY`.
17+
By default, connection is validated after being in the pool for 5 seconds. (https://github.com/ClickHouse/clickhouse-java/pull/1722)
18+
19+
### Bug Fixes
20+
- [Client-V2] Fix parsing endpoint URL to detect HTTPs (https://github.com/ClickHouse/clickhouse-java/issues/1718)
21+
- [Client-V2] Fix handling asynchronous operations. Less extra threads created now. (https://github.com/ClickHouse/clickhouse-java/issues/1691)
22+
- [Client-V2] Fix way of how settings are validated to let unsupported options to be added (https://github.com/ClickHouse/clickhouse-java/issues/1691)
23+
- [Client-V1] Fix getting `localhost` effective IP address (https://github.com/ClickHouse/clickhouse-java/issues/1729)
24+
- [Client-V2] Make client instance closeable to free underlying resource (https://github.com/ClickHouse/clickhouse-java/pull/1733)
225

326
## 0.6.2
427

clickhouse-client/src/main/java/com/clickhouse/client/config/ClickHouseClientOption.java

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -436,6 +436,7 @@ public enum ClickHouseClientOption implements ClickHouseOption {
436436
private static final Map<String, ClickHouseClientOption> options;
437437

438438
static final String UNKNOWN = "unknown";
439+
public static final String LATEST_KNOWN_VERSION = "0.6.3";
439440

440441
/**
441442
* Semantic version of the product.
@@ -480,9 +481,11 @@ public enum ClickHouseClientOption implements ClickHouseOption {
480481
ver = parts[3];
481482
PRODUCT_REVISION = ver.substring(0, ver.length() - 1);
482483
} else { // perhaps try harder by checking version from pom.xml?
483-
PRODUCT_VERSION = UNKNOWN;
484+
PRODUCT_VERSION = LATEST_KNOWN_VERSION;
484485
PRODUCT_REVISION = UNKNOWN;
485486
}
487+
488+
486489
CLIENT_OS_INFO = new StringBuilder().append(getSystemConfig("os.name", "O/S")).append('/')
487490
.append(getSystemConfig("os.version", UNKNOWN)).toString();
488491
String javaVersion = System.getProperty("java.vendor.version");
@@ -510,15 +513,18 @@ public enum ClickHouseClientOption implements ClickHouseOption {
510513
* @param additionalProperty additional property if any
511514
* @return non-empty user-agent
512515
*/
513-
public static final String buildUserAgent(String productName, String additionalProperty) {
514-
productName = productName == null || productName.isEmpty() ? (String) PRODUCT_NAME.getEffectiveDefaultValue()
515-
: productName.trim();
516-
StringBuilder builder = new StringBuilder(productName).append('/').append(PRODUCT_VERSION).append(" (")
517-
.append(CLIENT_OS_INFO).append("; ").append(CLIENT_JVM_INFO);
516+
public static String buildUserAgent(String productName, String additionalProperty) {
517+
productName = productName == null || productName.isEmpty() ? (String) PRODUCT_NAME.getEffectiveDefaultValue() : productName.trim();
518+
StringBuilder builder = new StringBuilder(productName).append(PRODUCT_VERSION.isEmpty() ? "" : "/" + PRODUCT_VERSION);
519+
520+
if (!String.valueOf(PRODUCT_NAME.getDefaultValue()).equals(productName)) {//Append if someone changed the original value
521+
builder.append(" ").append(PRODUCT_NAME.getDefaultValue()).append(LATEST_KNOWN_VERSION);
522+
}
523+
builder.append(" (").append(CLIENT_JVM_INFO);
518524
if (additionalProperty != null && !additionalProperty.isEmpty()) {
519525
builder.append("; ").append(additionalProperty.trim());
520526
}
521-
return builder.append("; rv:").append(PRODUCT_REVISION).append(')').toString();
527+
return builder.append(")").toString();
522528
}
523529

524530
/**

clickhouse-client/src/test/java/com/clickhouse/client/ClickHouseConfigTest.java

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ public void testCustomValues() {
7474
@Test(groups = { "unit" })
7575
public void testClientInfo() throws UnknownHostException {
7676
ClickHouseConfig config = new ClickHouseConfig();
77-
Assert.assertEquals(config.getProductVersion(), "unknown");
77+
Assert.assertEquals(config.getProductVersion(), ClickHouseClientOption.LATEST_KNOWN_VERSION);
7878
Assert.assertEquals(config.getProductRevision(), "unknown");
7979
Assert.assertEquals(config.getClientOsInfo(),
8080
System.getProperty("os.name") + "/" + System.getProperty("os.version"));
@@ -85,11 +85,10 @@ public void testClientInfo() throws UnknownHostException {
8585
Assert.assertEquals(config.getClientHost(), InetAddress.getLocalHost().getHostName());
8686

8787
Assert.assertEquals(ClickHouseClientOption.buildUserAgent(null, null),
88-
"ClickHouse-JavaClient/unknown (" + System.getProperty("os.name") + "/"
89-
+ System.getProperty("os.version") + "; " + System.getProperty("java.vm.name") + "/"
88+
"ClickHouse-JavaClient/"+ ClickHouseClientOption.PRODUCT_VERSION + " (" + System.getProperty("java.vm.name") + "/"
9089
+ System.getProperty("java.vendor.version",
9190
System.getProperty("java.vm.version", System.getProperty("java.version", "unknown")))
92-
+ "; rv:unknown)");
91+
+ ")");
9392
Assert.assertEquals(ClickHouseClientOption.buildUserAgent(null, null),
9493
ClickHouseClientOption.buildUserAgent("", null));
9594

clickhouse-http-client/src/main/java/com/clickhouse/client/http/ClickHouseHttpClient.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,14 +48,15 @@ private static HostNameAndAddress getLocalHost() {
4848
try {
4949
Enumeration<NetworkInterface> networkInterfaces = NetworkInterface.getNetworkInterfaces();
5050

51+
outer:
5152
for (NetworkInterface ni : Collections.list(networkInterfaces)) {
5253
Enumeration<InetAddress> inetAddresses = ni.getInetAddresses();
5354
for (InetAddress ia : Collections.list(inetAddresses)) {
5455
// We just use the first non-loopback address
55-
if (!ia.isLoopbackAddress()) {
56+
if (!ia.isLoopbackAddress() && !ia.isLinkLocalAddress()) {
5657
hostNameAndAddress.address = ia.getHostAddress();
5758
hostNameAndAddress.hostName = ia.getCanonicalHostName();
58-
break;
59+
break outer;
5960
}
6061
}
6162
}

clickhouse-http-client/src/main/java/com/clickhouse/client/http/ClickHouseHttpConnection.java

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -420,14 +420,18 @@ protected String getDefaultUserAgent() {
420420
protected final String getUserAgent() {
421421
final ClickHouseConfig c = config;
422422
String name = c.getClientName();
423+
String userAgent = getDefaultUserAgent();
424+
423425
if (!ClickHouseClientOption.CLIENT_NAME.getDefaultValue().equals(name)) {
424-
return name;
426+
return name + " " + userAgent;
425427
}
426428

427-
String userAgent = getDefaultUserAgent();
428429
name = c.getProductName();
429-
return ClickHouseClientOption.PRODUCT_NAME.getDefaultValue().equals(name) ? userAgent
430-
: new StringBuilder(name).append(userAgent.substring(userAgent.indexOf('/'))).toString();
430+
String version = c.getProductVersion();
431+
if (!ClickHouseClientOption.PRODUCT_VERSION.equals(version)) {
432+
name = name + "/" + c.getProductVersion();
433+
}
434+
return ClickHouseClientOption.PRODUCT_NAME.getDefaultValue().equals(name) ? userAgent : name + " " + userAgent;
431435
}
432436

433437
/**

0 commit comments

Comments
 (0)