Skip to content

Commit b8a3984

Browse files
committed
Fix(clickhouse-client): Log the exception instead of printing the stacktrace when an error occur during a ping
1 parent dd7d4f5 commit b8a3984

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

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

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,8 @@
4040
import com.clickhouse.data.ClickHouseValue;
4141
import com.clickhouse.data.ClickHouseValues;
4242
import com.clickhouse.data.ClickHouseWriter;
43+
import com.clickhouse.logging.Logger;
44+
import com.clickhouse.logging.LoggerFactory;
4345

4446
/**
4547
* A unified interface defines Java client for ClickHouse. A client can only
@@ -56,6 +58,7 @@
5658
* implementation properly in runtime.
5759
*/
5860
public interface ClickHouseClient extends AutoCloseable {
61+
Logger LOG = LoggerFactory.getLogger(ClickHouseClient.class);
5962

6063
/**
6164
* Returns a builder for creating a new client.
@@ -959,8 +962,8 @@ default boolean ping(ClickHouseNode server, int timeout) {
959962
.get(timeout, TimeUnit.MILLISECONDS)) {
960963
return resp != null;
961964
} catch (Exception e) {
962-
// ignore
963-
e.printStackTrace();
965+
LOG.debug("Failed to connect to the server", e);
966+
return false;
964967
}
965968
}
966969

0 commit comments

Comments
 (0)