Skip to content

Commit 53916f7

Browse files
committed
Merge branch 'main' into fix_duplicate_queryId
2 parents 779b7d2 + 6539f9c commit 53916f7

File tree

7 files changed

+66
-26
lines changed

7 files changed

+66
-26
lines changed

.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.0"
15+
CHC_VERSION: "0.6.1"
1616

1717
jobs:
1818
nightly:

.github/workflows/release.yml

Lines changed: 5 additions & 5 deletions
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.0-SNAPSHOT"
9+
default: "0.6.1-SNAPSHOT"
1010

1111
jobs:
1212
release:
@@ -57,8 +57,8 @@ jobs:
5757
maven_args: -q --batch-mode
5858
gpg_private_key: ${{ secrets.GPG_PRIVATE_KEY }}
5959
gpg_passphrase: ${{ secrets.GPG_PASSPHRASE }}
60-
nexus_username: ${{ secrets.SONATYPE_USER }}
61-
nexus_password: ${{ secrets.SONATYPE_PASSWD }}
60+
nexus_username: ${{ secrets.SONATYPE_TOKEN_USER }}
61+
nexus_password: ${{ secrets.SONATYPE_TOKEN }}
6262
- name: Release R2DBC 0.9.1
6363
uses: samuelmeuli/action-maven-publish@v1
6464
with:
@@ -67,8 +67,8 @@ jobs:
6767
maven_args: -q --batch-mode -Dr2dbc-spi.version=0.9.1.RELEASE
6868
gpg_private_key: ${{ secrets.GPG_PRIVATE_KEY }}
6969
gpg_passphrase: ${{ secrets.GPG_PASSPHRASE }}
70-
nexus_username: ${{ secrets.SONATYPE_USER }}
71-
nexus_password: ${{ secrets.SONATYPE_PASSWD }}
70+
nexus_username: ${{ secrets.SONATYPE_TOKEN_USER }}
71+
nexus_password: ${{ secrets.SONATYPE_TOKEN }}
7272
- name: Create Pre-release on Github
7373
uses: "zhicwu/action-automatic-releases@latest"
7474
with:

clickhouse-client/src/main/java/com/clickhouse/client/ClickHouseNode.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -787,7 +787,10 @@ public static ClickHouseNode of(String uri, Map<?, ?> options) {
787787
String scheme = normalizedUri.getScheme();
788788
ClickHouseProtocol protocol = ClickHouseProtocol.fromUriScheme(scheme);
789789
int port = extract(scheme, normalizedUri.getPort(), protocol, params);
790-
790+
if ((options == null || options.get(ClickHouseClientOption.SSL.getKey()) == null)
791+
&& scheme.equalsIgnoreCase("https")) {
792+
params.put(ClickHouseClientOption.SSL.getKey(), "true");
793+
}
791794
ClickHouseCredentials credentials = extract(normalizedUri.getRawUserInfo(), params, null);
792795

793796
return new ClickHouseNode(normalizedUri.getHost(), protocol, port, credentials, params, tags);

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

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -191,7 +191,11 @@ public Builder addEndpoint(Protocol protocol, String host, int port, boolean sec
191191
ValidationUtils.checkNonBlank(host, "host");
192192
ValidationUtils.checkNotNull(protocol, "protocol");
193193
ValidationUtils.checkRange(port, 1, ValidationUtils.TCP_PORT_NUMBER_MAX, "port");
194-
194+
if (secure) {
195+
// For some reason com.clickhouse.client.http.ApacheHttpConnectionImpl.newConnection checks only client config
196+
// for SSL, so we need to set it here. But it actually should be set for each node separately.
197+
this.configuration.put(ClickHouseClientOption.SSL.getKey(), "true");
198+
}
195199
String endpoint = String.format("%s%s://%s:%d", protocol.toString().toLowerCase(), secure ? "s": "", host, port);
196200
this.addEndpoint(endpoint);
197201
return this;

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

Lines changed: 18 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -18,27 +18,29 @@
1818

1919
public class ClientV1AdaptorHelper {
2020

21-
private static void copyProxySettings(Map<ClickHouseOption, Serializable> target, Map<String, String> config) {
22-
ClickHouseClientOption opt = ClickHouseClientOption.PROXY_HOST;
23-
String value = config.get(opt.getKey());
24-
if (value != null) {
25-
target.put(opt, value);
26-
}
27-
opt = ClickHouseClientOption.PROXY_PORT;
28-
value = config.get(opt.getKey());
29-
if (value != null) {
30-
target.put(opt, Integer.parseInt(value));
31-
}
32-
opt = ClickHouseClientOption.PROXY_TYPE;
33-
value = config.get(opt.getKey());
34-
if (value != null) {
35-
target.put(opt, ClickHouseProxyType.valueOf(value));
21+
private static void copyClientOptions(Map<ClickHouseOption, Serializable> target, Map<String, String> config) {
22+
23+
for (ClickHouseClientOption opt : ClickHouseClientOption.values()) {
24+
String value = config.get(opt.getKey());
25+
if (value == null) {
26+
continue;
27+
}
28+
29+
if (opt.getValueType().isAssignableFrom(Integer.class)) {
30+
target.put(opt, Integer.parseInt(value));
31+
} else if (opt.getValueType().isAssignableFrom(Boolean.class)) {
32+
target.put(opt, Boolean.parseBoolean(value));
33+
} else if (opt.getValueType().isEnum()) {
34+
target.put(opt, Enum.valueOf((Class<Enum>) opt.getValueType(), value));
35+
} else if (opt.getValueType().isAssignableFrom(String.class)) {
36+
target.put(opt, value);
37+
}
3638
}
3739
}
3840

3941
public static ClickHouseClient createClient(Map<String, String> configuration) {
4042
Map<ClickHouseOption, Serializable> config = new HashMap<>();
41-
copyProxySettings(config, configuration);
43+
copyClientOptions(config, configuration);
4244

4345
ClickHouseConfig clientConfig = new ClickHouseConfig(config);
4446

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
package com.clickhouse.client;
2+
3+
import com.clickhouse.client.api.Client;
4+
import com.clickhouse.client.api.enums.Protocol;
5+
import com.clickhouse.client.api.query.GenericRecord;
6+
import org.junit.Assert;
7+
import org.testng.annotations.Test;
8+
9+
import java.util.Optional;
10+
11+
public class ClientTests extends BaseIntegrationTest {
12+
13+
14+
@Test(enabled = false)
15+
public void testWithSSL() {
16+
17+
ClickHouseNode secureNode = getSecureServer(ClickHouseProtocol.HTTP);
18+
Client client = new Client.Builder()
19+
.addEndpoint(Protocol.HTTP, "localhost", secureNode.getPort(), true)
20+
.setUsername("default")
21+
.setPassword("")
22+
.build();
23+
24+
25+
Optional<GenericRecord> genericRecord = client
26+
.queryAll("SELECT hostname()").stream().findFirst();
27+
Assert.assertTrue(genericRecord.isPresent());
28+
29+
System.out.println(genericRecord.get().getString(1));
30+
}
31+
}

pom.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -85,8 +85,8 @@
8585
</distributionManagement>
8686

8787
<properties>
88-
<revision>0.6.0-SNAPSHOT</revision>
89-
<project.current.year>2023</project.current.year>
88+
<revision>0.6.1-SNAPSHOT</revision>
89+
<project.current.year>2024</project.current.year>
9090
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
9191
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
9292

0 commit comments

Comments
 (0)