Skip to content
Merged
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;

/**
* Transport-layer exception that is hard to categorize as connection initiation or data transfer.
* These exceptions are not retryable by default.
* Main purpose of this exception is to wrap transport-specific failures (e.g., SSL errors).
*/
Comment thread
chernser marked this conversation as resolved.
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 thread
chernser marked this conversation as resolved.

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,31 @@ 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()) {

final String queryId = "test-failure-query-id";
TransportException tex = Assert.expectThrows(TransportException.class,
() -> client.query("SELECT 1", new QuerySettings().setQueryId(queryId)).get());
Assert.assertTrue(tex.getMessage().startsWith("SSL Problem"), "Unexpected message: " + tex.getMessage());
Assert.assertEquals(tex.getQueryId(), queryId);
Assert.assertTrue(tex.getCause() instanceof javax.net.ssl.SSLException,
"Expected SSLException cause but was: " + tex.getCause());
}
}

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