Repository navigation
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
|
TriageCategory: Summary What this impacts
Concerns
Required reviewer action
|
|
@cursor review |
There was a problem hiding this comment.
🟡 Changes recommended
Unresolved issues can mask transfer failures, leave JDBC connections open after compressed-result network timeouts, and cause false data-mismatch test failures after insert retries.
3 open issues
What changed in this PR
This PR hardens native LZ4/ZSTD compression in client-v2 and expands coverage for #3321.
Changes:
- Validates compressed block sizes, codec results, stream arguments, and output lifecycle.
- Preserves plain-text HTTP error messages when response compression is enabled.
- Adds malformed-stream tests and randomized, multi-block integration tests, with explicit codec selection.
Compatibility: Method signatures remain unchanged, but stricter validation and new DataTransferException wrapping change observable failure behavior. These changes should be documented in the changelog and feature contract.
Tests were not run because project dependencies are unavailable in this review environment.
| File | Description |
|---|---|
client-v2/src/test/java/com/clickhouse/client/query/QueryServerContentZSTDCompressionTests.java |
Explicitly selects ZSTD for query tests. |
client-v2/src/test/java/com/clickhouse/client/query/QueryServerContentLZ4CompressionTests.java |
Explicitly selects LZ4 for query tests. |
client-v2/src/test/java/com/clickhouse/client/insert/InsertTests.java |
Adds incompressible multi-block round-trip coverage. |
client-v2/src/test/java/com/clickhouse/client/insert/InsertClientContentZSTDCompressionTests.java |
Selects ZSTD for secure insert tests. |
client-v2/src/test/java/com/clickhouse/client/insert/InsertClientContentLZ4CompressionTests.java |
Selects LZ4 for secure insert tests. |
client-v2/src/test/java/com/clickhouse/client/insert/CompressionStreamRoundTripTests.java |
Adds randomized LZ4/ZSTD integration round trips. |
client-v2/src/test/java/com/clickhouse/client/api/internal/HttpAPIClientHelperTest.java |
Covers plain-text errors and bounded error-body recovery. |
client-v2/src/test/java/com/clickhouse/client/api/internal/CompressedBlockOutputStreamTest.java |
Tests block boundaries, validation, and close failures. |
client-v2/src/test/java/com/clickhouse/client/api/internal/CompressedBlockInputStreamTest.java |
Tests truncation, corrupt headers, and codec size mismatches. |
client-v2/src/test/java/com/clickhouse/client/api/data_formats/internal/BinaryStreamReaderTests.java |
Checks transfer-exception wrapping. |
client-v2/src/main/java/com/clickhouse/client/api/internal/HttpAPIClientHelper.java |
Bounds error-body decoding and preserves consumed headers. |
client-v2/src/main/java/com/clickhouse/client/api/internal/CompressedBlockOutputStream.java |
Validates writes and strengthens close handling. |
client-v2/src/main/java/com/clickhouse/client/api/internal/CompressedBlockInputStream.java |
Validates blocks and wraps read failures. |
Review effort: Balanced
|
Docs drift check: this PR looks like it needs doc updates.
|
|
There was a problem hiding this comment.
Automated approval by the AI review gate.
The required AI review gate concluded SUCCESS on 772f48f, and this change touches no path that requires a human reviewer. This approval is posted by an automated identity (security-ai-gate-reviewer[bot]), not a human, and is bound to the evaluated commit. A new push dismisses it and re-evaluates.
repo=ClickHouse/clickhouse-java pr=#3322 head=772f48f09311983bea2005b7e62c7d622ca6179a
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes using high effort and found 1 potential issue.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, have a team admin enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit 6af4087. Configure here.
| if (compressedSizeWithHeader > maxBlockSize) { | ||
| throw new DataTransferException("Corrupted stream: compressed block size " + compressedSizeWithHeader | ||
| + " exceeds configured limit " + maxBlockSize); | ||
| } |
There was a problem hiding this comment.
Block size cap rejects valid blocks
Medium Severity
The read path applies maxBlockSize to compressedSizeWithHeader, which includes the 9-byte inner header and can exceed uncompressed size for incompressible LZ4/ZSTD data. The documented 1 MiB minimum is meant to match server max_compress_block_size (uncompressed), so a client set to that minimum can reject ordinary incompressible 1 MiB blocks with a DataTransferException.
Additional Locations (1)
Reviewed by Cursor Bugbot for commit 6af4087. Configure here.
AI review gate — Cursor Bugbot found issues
Unresolved findings (1): What to do:
Re-run the gate with “Re-run jobs” after an approval or a finished review. A push re-runs it automatically. |






Description
Closes: #3321
Note
Medium Risk
Breaking exception type on compressed reads affects callers and JDBC timeout handling; the 64 MiB default block cap can reject legitimate larger server blocks unless configured.
Overview
Breaking: Malformed or truncated native LZ4/ZSTD blocks now fail with
DataTransferException(with query id where applicable) instead of mixedIOException/EOFException/ClientException. High-level query APIs rethrow that type unchanged; HTTP response reads wrap I/O failures similarly.Adds
compression.max_block_size(default 64 MiB, range 1 MiB–1 GiB) andClient.Builder#setMaxCompressionBlockSize, wired throughCompressedBlockInputStream/ output paths so oversized headers and codec size mismatches are rejected before large allocations.Compression stack: stricter constructor and block validation, safer
CompressedBlockOutputStreamclose/flush behavior, and improved plain-text error body handling when response compression is enabled. JDBC treatsSocketTimeoutExceptionnested under transfer failures as a network timeout viahasCause.Docs (0.12.0 migration), feature notes, and broad unit/integration tests cover the new limits and exception behavior.
Reviewed by Cursor Bugbot for commit 6af4087. Bugbot is set up for automated code reviews on this repo. Configure here.