Skip to content

Commit 186efac

Browse files
committed
Adjusting version string
1 parent 34ef20b commit 186efac

File tree

3 files changed

+10
-4
lines changed

3 files changed

+10
-4
lines changed

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

Lines changed: 3 additions & 2 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,7 +481,7 @@ 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 = "";
484+
PRODUCT_VERSION = LATEST_KNOWN_VERSION;
484485
PRODUCT_REVISION = UNKNOWN;
485486
}
486487

@@ -517,7 +518,7 @@ public static String buildUserAgent(String productName, String additionalPropert
517518
StringBuilder builder = new StringBuilder(productName).append(PRODUCT_VERSION.isEmpty() ? "" : "/" + PRODUCT_VERSION);
518519

519520
if (!String.valueOf(PRODUCT_NAME.getDefaultValue()).equals(productName)) {//Append if someone changed the original value
520-
builder.append(" ").append(PRODUCT_NAME.getDefaultValue()).append(PRODUCT_VERSION.isEmpty() ? "" : "/" + PRODUCT_VERSION);
521+
builder.append(" ").append(PRODUCT_NAME.getDefaultValue()).append(LATEST_KNOWN_VERSION);
521522
}
522523
builder.append(" (").append(CLIENT_JVM_INFO);
523524
if (additionalProperty != null && !additionalProperty.isEmpty()) {

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -427,6 +427,10 @@ protected final String getUserAgent() {
427427
}
428428

429429
name = c.getProductName();
430+
String version = c.getProductVersion();
431+
if (!ClickHouseClientOption.PRODUCT_VERSION.equals(version)) {
432+
name = name + "/" + c.getProductVersion();
433+
}
430434
return ClickHouseClientOption.PRODUCT_NAME.getDefaultValue().equals(name) ? userAgent : name + " " + userAgent;
431435
}
432436

clickhouse-http-client/src/test/java/com/clickhouse/client/http/ClickHouseHttpClientTest.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,8 @@ public void testUserAgent() throws Exception {
175175
.query("select http_user_agent from system.query_log where query='select ''" + uuid + "'''")
176176
.executeAndWait()) {
177177
String result = response.firstRecord().getValue(0).asString();
178-
Assert.assertTrue(result.startsWith("MyCustomClient"));
178+
System.out.println(result);
179+
Assert.assertTrue(result.startsWith("MyCustomClient ClickHouse-JavaClient/"));
179180
Assert.assertTrue(result.indexOf("Http") > 0);
180181
}
181182

@@ -194,7 +195,7 @@ public void testUserAgent() throws Exception {
194195
.query("select http_user_agent from system.query_log where query='select ''" + uuid + "'''")
195196
.executeAndWait()) {
196197
String result = response.firstRecord().getValue(0).asString();
197-
Assert.assertTrue(result.startsWith("MyCustomClient"));
198+
Assert.assertTrue(result.startsWith("MyCustomClient ClickHouse-JavaClient/"));
198199
}
199200
}
200201

0 commit comments

Comments
 (0)