Skip to content

Commit 1d522f2

Browse files
committed
Merge branch 'main' into v2_jwt_auth
2 parents 4160024 + bf1284d commit 1d522f2

File tree

108 files changed

+12537
-1078
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

108 files changed

+12537
-1078
lines changed

.github/workflows/build.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,7 @@ jobs:
153153
matrix:
154154
# most recent LTS releases as well as latest stable builds
155155
# https://github.com/ClickHouse/ClickHouse/pulls?q=is%3Aopen+is%3Apr+label%3Arelease
156-
clickhouse: ["23.8", "24.3", "24.6", "latest"]
156+
clickhouse: ["23.8", "24.3", "24.8", "latest"]
157157
fail-fast: false
158158
timeout-minutes: 15
159159
name: Java client + CH ${{ matrix.clickhouse }}
@@ -335,7 +335,7 @@ jobs:
335335
needs: compile
336336
strategy:
337337
matrix:
338-
clickhouse: ["23.8", "24.3", "24.6", "latest"]
338+
clickhouse: ["23.8", "24.3", "24.8", "latest"]
339339
# grpc is not fully supported, and http_client and apache_http_client do not work in CI environment(due to limited threads?)
340340
protocol: ["http"]
341341
r2dbc: ["1.0.0.RELEASE", "0.9.1.RELEASE"]
@@ -452,7 +452,7 @@ jobs:
452452
matrix:
453453
# most recent LTS releases as well as latest stable builds
454454
# https://github.com/ClickHouse/ClickHouse/pulls?q=is%3Aopen+is%3Apr+label%3Arelease
455-
clickhouse: ["24.6", "latest"]
455+
clickhouse: ["24.3", "24.8", "latest"]
456456
fail-fast: false
457457
timeout-minutes: 15
458458
name: Client V2 + CH ${{ matrix.clickhouse }}

.github/workflows/nightly.yml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ on:
1313
env:
1414
CHC_BRANCH: "main"
1515
CHC_VERSION: "0.7.1"
16+
CH_VERSION: "24.8"
1617

1718
jobs:
1819
nightly:
@@ -66,7 +67,7 @@ jobs:
6667
uses: samuelmeuli/action-maven-publish@v1
6768
with:
6869
maven_profiles: release
69-
maven_args: -q --batch-mode
70+
maven_args: -q --batch-mode -DclickhouseVersion=${{ env.CH_VERSION }}
7071
gpg_private_key: ${{ secrets.GPG_PRIVATE_KEY }}
7172
gpg_passphrase: ${{ secrets.GPG_PASSPHRASE }}
7273
nexus_username: ${{ secrets.SONATYPE_TOKEN_USER }}
@@ -76,7 +77,7 @@ jobs:
7677
with:
7778
directory: clickhouse-r2dbc
7879
maven_profiles: release
79-
maven_args: -q --batch-mode -Dr2dbc-spi.version=0.9.1.RELEASE
80+
maven_args: -q --batch-mode -Dr2dbc-spi.version=0.9.1.RELEASE -DclickhouseVersion=${{ env.CH_VERSION }}
8081
gpg_private_key: ${{ secrets.GPG_PRIVATE_KEY }}
8182
gpg_passphrase: ${{ secrets.GPG_PASSPHRASE }}
8283
nexus_username: ${{ secrets.SONATYPE_TOKEN_USER }}

.github/workflows/release.yml

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,9 @@ on:
88
required: true
99
default: "0.7.1-SNAPSHOT"
1010

11+
env:
12+
CH_VERSION: "24.8"
13+
1114
jobs:
1215
release:
1316
name: "Build and Publish Artifact"
@@ -54,7 +57,7 @@ jobs:
5457
uses: samuelmeuli/action-maven-publish@v1
5558
with:
5659
maven_profiles: release
57-
maven_args: -q --batch-mode
60+
maven_args: -q --batch-mode -DclickhouseVersion=${{ env.CH_VERSION }}
5861
gpg_private_key: ${{ secrets.GPG_PRIVATE_KEY }}
5962
gpg_passphrase: ${{ secrets.GPG_PASSPHRASE }}
6063
nexus_username: ${{ secrets.SONATYPE_TOKEN_USER }}
@@ -64,7 +67,7 @@ jobs:
6467
with:
6568
directory: clickhouse-r2dbc
6669
maven_profiles: release
67-
maven_args: -q --batch-mode -Dr2dbc-spi.version=0.9.1.RELEASE
70+
maven_args: -q --batch-mode -Dr2dbc-spi.version=0.9.1.RELEASE -DclickhouseVersion=${{ env.CH_VERSION }}
6871
gpg_private_key: ${{ secrets.GPG_PRIVATE_KEY }}
6972
gpg_passphrase: ${{ secrets.GPG_PASSPHRASE }}
7073
nexus_username: ${{ secrets.SONATYPE_TOKEN_USER }}

CHANGELOG.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,15 @@
1+
## Latest
2+
3+
### New Features
4+
- Added basic auth support for proxies. Now you can specify username/password when connecting via a proxy that requires it with HttpURLConnection and Apache HttpClient.
5+
6+
## 0.7.1-patch1
7+
8+
### Bug Fixes
9+
- [JDBC] Fixed `java.lang.NoClassDefFoundError: com/clickhouse/client/internal/apache/hc/core5/http2/HttpVersionPolicy` (https://github.com/ClickHouse/clickhouse-java/issues/1912)
10+
- [client-v2] Fixed multiple issues with error message handling. (https://github.com/ClickHouse/clickhouse-java/issues/1906)
11+
- [client-v2] Fixed primitive types conversion. Now client correctly handles numbers to boolean and vice-versa. (https://github.com/ClickHouse/clickhouse-java/issues/1908)
12+
113
## 0.7.1
214

315
### New Features

README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,8 @@ Old client still be used when:
5454
### Upcomming deprecations:
5555
| Component | Version | Comment |
5656
|--------------------------------|---------|--------------------------------------------------|
57-
| Clickhouse CLI Client (Java) | 0.7.0 | Please use `clickhouse-client` (see https://clickhouse.com/docs/en/interfaces/cli#clickhouse-client) |
57+
| ClickHouse Java v1 | TBC | We'll be deprecating Java v1 in 2025 |
58+
| ClickHouse CLI Client (Java) | 0.7.0 | Please use `clickhouse-client` (see https://clickhouse.com/docs/en/interfaces/cli#clickhouse-client) |
5859
| ClickHouse GRPC Client | 0.7.0 | Please use the ClickHouse http client instead. GRPC protos still available https://github.com/ClickHouse/ClickHouse/tree/master/src/Server/grpc_protos |
5960

6061

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

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -245,6 +245,8 @@ public static Map<ClickHouseOption, Serializable> toClientOptions(Map<?, ?> prop
245245
private final ClickHouseProxyType proxyType;
246246
private final String proxyHost;
247247
private final int proxyPort;
248+
private final String proxyUserName;
249+
private final char[] proxyPassword;
248250
// client specific options
249251
private final Map<ClickHouseOption, Serializable> options;
250252
private final ClickHouseCredentials credentials;
@@ -383,6 +385,8 @@ public ClickHouseConfig(Map<ClickHouseOption, Serializable> options, ClickHouseC
383385
this.proxyType = getOption(ClickHouseClientOption.PROXY_TYPE, ClickHouseProxyType.class);
384386
this.proxyHost = getStrOption(ClickHouseClientOption.PROXY_HOST);
385387
this.proxyPort = getIntOption(ClickHouseClientOption.PROXY_PORT);
388+
this.proxyUserName = getStrOption(ClickHouseClientOption.PROXY_USERNAME);
389+
this.proxyPassword = getStrOption(ClickHouseClientOption.PROXY_PASSWORD).toCharArray();
386390
}
387391

388392
@Override
@@ -674,14 +678,6 @@ public boolean isUseObjectsInArray() {
674678
return useObjectsInArray;
675679
}
676680

677-
/**
678-
* Checks whether no proxy is used or not.
679-
*
680-
* @return true if no proxy is used; false otherwise
681-
* @deprecated will be dropped in 0.5, please use {@link #getProxyType()}
682-
* instead
683-
*/
684-
685681
public ClickHouseProxyType getProxyType() {
686682
return proxyType;
687683
}
@@ -694,6 +690,14 @@ public int getProxyPort() {
694690
return proxyPort;
695691
}
696692

693+
public String getProxyUserName() {
694+
return proxyUserName;
695+
}
696+
697+
public char[] getProxyPassword() {
698+
return proxyPassword;
699+
}
700+
697701
public boolean isUseServerTimeZone() {
698702
return useServerTimeZone;
699703
}

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

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -218,6 +218,8 @@ public enum ClickHouseClientOption implements ClickHouseOption {
218218
MAX_RESULT_ROWS("max_result_rows", 0L,
219219
"Limit on the number of rows in the result. "
220220
+ "Also checked for subqueries, and on remote servers when running parts of a distributed query."),
221+
222+
RESULT_OVERFLOW_MODE("result_overflow_mode", "throw","What to do if the result is overflowed."),
221223
/**
222224
* Maximum size of thread pool for each client.
223225
*/
@@ -402,7 +404,15 @@ public enum ClickHouseClientOption implements ClickHouseOption {
402404
/**
403405
* Set ClickHouse proxy port.
404406
*/
405-
PROXY_PORT("proxy_port", -1, "Set ClickHouse server proxy hostname."),
407+
PROXY_PORT("proxy_port", -1, "Set ClickHouse server proxy port."),
408+
/**
409+
* Set Clickhouse proxy username.
410+
*/
411+
PROXY_USERNAME("proxy_username", "", "Set ClickHouse server proxy username."),
412+
/**
413+
* Set ClickHouse proxy password.
414+
*/
415+
PROXY_PASSWORD("proxy_password", "", "Set ClickHouse server proxy password."),
406416
/**
407417
* Whether to use server time zone.
408418
*/

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

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -172,6 +172,7 @@ public class ClickHouseServerForTest {
172172
ClickHouseProtocol.TCP.getDefaultSecurePort(),
173173
ClickHouseProtocol.POSTGRESQL.getDefaultPort())
174174
.withClasspathResourceMapping("containers/clickhouse-server", customDirectory, BindMode.READ_ONLY)
175+
.withClasspathResourceMapping("empty.csv", "/var/lib/clickhouse/user_files/empty.csv", BindMode.READ_ONLY)
175176
.withFileSystemBind(System.getProperty("java.io.tmpdir"), getClickHouseContainerTmpDir(),
176177
BindMode.READ_WRITE)
177178
.withNetwork(network)
@@ -323,10 +324,12 @@ public static boolean isCloud() {
323324

324325
@BeforeSuite(groups = {"integration"})
325326
public static void beforeSuite() {
326-
if (isCloud()) {
327+
if (isCloud) {
327328
if (!runQuery("CREATE DATABASE IF NOT EXISTS " + database)) {
328329
throw new IllegalStateException("Failed to create database for testing.");
329330
}
331+
332+
return;
330333
}
331334

332335
if (clickhouseContainer != null) {
@@ -336,6 +339,10 @@ public static void beforeSuite() {
336339

337340
try {
338341
clickhouseContainer.start();
342+
343+
if (clickhouseContainer.isRunning()) {
344+
runQuery("CREATE DATABASE IF NOT EXISTS " + database);
345+
}
339346
} catch (RuntimeException e) {
340347
throw new IllegalStateException(new StringBuilder()
341348
.append("Failed to start docker container for integration test.\r\n")
@@ -352,7 +359,7 @@ public static void afterSuite() {
352359
clickhouseContainer.stop();
353360
}
354361

355-
if (isCloud()) {
362+
if (isCloud) {
356363
if (!runQuery("DROP DATABASE IF EXISTS " + database)) {
357364
LOGGER.warn("Failed to drop database for testing.");
358365
}

clickhouse-client/src/test/resources/empty.csv

Whitespace-only changes.

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

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,12 @@
1919
import com.clickhouse.data.ClickHouseUtils;
2020
import com.clickhouse.logging.Logger;
2121
import com.clickhouse.logging.LoggerFactory;
22+
import org.apache.hc.client5.http.auth.AuthScope;
23+
import org.apache.hc.client5.http.auth.UsernamePasswordCredentials;
2224
import org.apache.hc.client5.http.classic.methods.HttpGet;
2325
import org.apache.hc.client5.http.classic.methods.HttpPost;
2426
import org.apache.hc.client5.http.config.ConnectionConfig;
27+
import org.apache.hc.client5.http.impl.auth.BasicCredentialsProvider;
2528
import org.apache.hc.client5.http.impl.classic.CloseableHttpClient;
2629
import org.apache.hc.client5.http.impl.classic.CloseableHttpResponse;
2730
import org.apache.hc.client5.http.impl.classic.HttpClientBuilder;
@@ -121,6 +124,14 @@ private CloseableHttpClient newConnection(ClickHouseConfig c) throws IOException
121124
}
122125
if (c.getProxyType() == ClickHouseProxyType.HTTP) {
123126
builder.setProxy(new HttpHost(c.getProxyHost(), c.getProxyPort()));
127+
128+
if (c.getProxyUserName() != null && c.getProxyUserName() != "") {
129+
AuthScope authScope = new AuthScope(c.getProxyHost(), c.getProxyPort());
130+
UsernamePasswordCredentials credentials = new UsernamePasswordCredentials(c.getProxyUserName(), c.getProxyPassword());
131+
BasicCredentialsProvider credsProvider = new BasicCredentialsProvider();
132+
credsProvider.setCredentials(authScope, credentials);
133+
builder.setDefaultCredentialsProvider(credsProvider);
134+
}
124135
}
125136
return builder.build();
126137
}

0 commit comments

Comments
 (0)