Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,8 @@ public ClientException(String message) {
public ClientException(String message, Throwable cause) {
super(message, cause);
}

public ClientException(String message, Throwable cause, String queryId) {
super(message, cause, queryId);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
package com.clickhouse.client.api;

/**
* Any exception that happens inside transport logic and hard to categorize as client logic
* like connection initiation or data transfer. These exceptions are not retriable normally.
* Main purpose of this exception is to wrap transport specific.
*/
Comment on lines +3 to +7
public class TransportException extends ClickHouseException {
public TransportException(String message, Throwable cause, String queryId) {
super(message, cause, queryId);
this.isRetryable = false;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
import com.clickhouse.client.api.ConnectionReuseStrategy;
import com.clickhouse.client.api.DataTransferException;
import com.clickhouse.client.api.ServerException;
import com.clickhouse.client.api.TransportException;
import com.clickhouse.client.api.enums.ProxyType;
import com.clickhouse.client.api.enums.SSLMode;
import com.clickhouse.client.api.http.ClickHouseHttpProto;
Expand Down Expand Up @@ -897,7 +898,7 @@ public RuntimeException wrapException(String message, Exception cause, String qu
}

if (cause instanceof SSLException) {
return new ClickHouseException("SSL Problem", cause, queryId);
return new TransportException("SSL Problem", cause, queryId);
}
Comment on lines 900 to 902

if (cause instanceof ConnectionRequestTimeoutException ||
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,11 @@
import com.clickhouse.client.api.Client;
import com.clickhouse.client.api.DataTransferException;
import com.clickhouse.client.api.ServerException;
import com.clickhouse.client.api.TransportException;
import com.clickhouse.client.api.enums.Protocol;
import com.clickhouse.client.api.query.QuerySettings;
import org.testng.Assert;
import org.testng.SkipException;
import org.testng.annotations.Test;

import java.time.temporal.ChronoUnit;
Expand Down Expand Up @@ -74,6 +76,27 @@ void testQueryTimeout() throws Exception {
}
}

@Test(groups = {"integration"})
void testTransportException() throws Exception {
if (isCloud()) {
throw new SkipException("SSL Configuration tests - no need to test on cloud");
}

ClickHouseNode secureServer = getSecureServer(ClickHouseProtocol.HTTP);

try (Client client = new Client.Builder()
.addEndpoint("https://localhost:" + secureServer.getPort())
.setUsername("default")
.setPassword(ClickHouseServerForTest.getPassword())
.compressClientRequest(true)
.build()) {

TransportException tex = Assert.expectThrows(TransportException.class,
() -> client.query("SELECT 1").get());
Assert.assertTrue(tex.getMessage().contains("SSL Problem"));
}
Comment on lines +87 to +97
}

protected Client.Builder newClient() {
ClickHouseNode node = getServer(ClickHouseProtocol.HTTP);
boolean isSecure = isCloud();
Expand Down
Loading