Conversation
Client V2 CoverageCoverage Report
Class Coverage
|
JDBC V2 CoverageCoverage Report
Class Coverage
|
JDBC V1 CoverageCoverage Report
Class Coverage
|
Client V1 CoverageCoverage Report
Class Coverage
|
There was a problem hiding this comment.
Pull Request Overview
This PR implements JDBC network timeout functionality by adding support for Connection#abort and Connection#setNetworkTimeout methods. The implementation includes timeout detection, connection abortion logic, and proper propagation of socket timeout exceptions throughout the JDBC stack.
- Implements
Connection#abortto properly close connections using an executor - Implements
Connection#setNetworkTimeoutwith timeout caching and connection closure on timeout - Adds network timeout detection and handling across statement execution classes
Reviewed Changes
Copilot reviewed 8 out of 8 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| ConnectionTest.java | Updates tests to verify abort and network timeout functionality instead of expecting unsupported feature exceptions |
| JdbcUtils.java | Adds utility method for safe resource cleanup with logging |
| WriterStatementImpl.java | Adds socket timeout detection and connection notification in write operations |
| StatementImpl.java | Adds socket timeout detection and connection notification in query execution |
| ResultSetImpl.java | Adds socket timeout detection and connection notification in result set iteration |
| ConnectionImpl.java | Implements abort and network timeout methods with proper executor handling |
| QuerySettings.java | Adds network timeout getter/setter methods for query configuration |
| InsertSettings.java | Adds network timeout methods and merge functionality for insert operations |
Comments suppressed due to low confidence (2)
jdbc-v2/src/main/java/com/clickhouse/jdbc/ConnectionImpl.java:272
- Converting Long to intValue() can cause data loss if the timeout value exceeds Integer.MAX_VALUE. Consider using the Long value directly or adding validation.
return TRANSACTION_NONE;
jdbc-v2/src/main/java/com/clickhouse/jdbc/ConnectionImpl.java:282
- Converting Long to intValue() can cause data loss if the timeout value exceeds Integer.MAX_VALUE. Consider using the Long value directly or adding validation.
public void clearWarnings() throws SQLException {
| } | ||
|
|
||
| public Long getNetworkTimeout() { | ||
| return (Long) rawSettings.get(ClientConfigProperties.SOCKET_OPERATION_TIMEOUT.getKey()); |
There was a problem hiding this comment.
Those methods are never used. Do you have any plans to add tests?
There was a problem hiding this comment.
yes, I'll test them.
| // Some connection pools set timeout before calling Connection#close() to ensure that this operation will not hang | ||
| // Socket timeout is propagated with QuerySettings this connection has. | ||
| networkTimeoutExecutor = executor; | ||
| defaultQuerySettings.setOption(ClientConfigProperties.SOCKET_OPERATION_TIMEOUT.getKey(), (long)milliseconds); |
There was a problem hiding this comment.
Why not use the new method setNetworkTimeout
|



Summary
Connection#abortConnection#setNetworkTimeoutand logic that caches timeout exception and closes a connectionCloses #2413
Checklist
Delete items not relevant to your PR: