This is an automated email from the ASF dual-hosted git repository.
chia7712 pushed a commit to branch 3.9
in repository https://gitbox.apache.org/repos/asf/kafka.git
The following commit(s) were added to refs/heads/3.9 by this push:
new 96e06ebe888 KAFKA-20361 Fix LazyDownConversionRecordsTest in using
zlib-ng (#21881)
96e06ebe888 is described below
commit 96e06ebe888059eb3178dada8aaac1cd85999d7a
Author: Murali Basani <[email protected]>
AuthorDate: Tue Mar 31 16:55:53 2026 +0200
KAFKA-20361 Fix LazyDownConversionRecordsTest in using zlib-ng (#21881)
The test's write loop passed bytesToConvert - written as the remaining
parameter to LazyDownConversionRecordsSend.writeTo(). This shrinks with
each batch written, and the last batch gets truncated via
Math.min(batchSize, remaining) when total V1 size exceeds V2 size —
which happens with zlib-ng due to its longer match sizes compressing V1
format less efficiently.
Fix: pass bytesToConvert (constant) as remaining so no individual batch
is ever truncated, regardless of the compression library used.
Reviewers: Chia-Ping Tsai <[email protected]>
---
.../org/apache/kafka/common/record/LazyDownConversionRecordsTest.java | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git
a/clients/src/test/java/org/apache/kafka/common/record/LazyDownConversionRecordsTest.java
b/clients/src/test/java/org/apache/kafka/common/record/LazyDownConversionRecordsTest.java
index 59ac60e3a80..33ed91f26ff 100644
---
a/clients/src/test/java/org/apache/kafka/common/record/LazyDownConversionRecordsTest.java
+++
b/clients/src/test/java/org/apache/kafka/common/record/LazyDownConversionRecordsTest.java
@@ -154,7 +154,8 @@ public class LazyDownConversionRecordsTest {
ByteBuffer convertedRecordsBuffer;
try (TransferableChannel channel =
toTransferableChannel(FileChannel.open(outputFile.toPath(),
StandardOpenOption.READ, StandardOpenOption.WRITE))) {
int written = 0;
- while (written < bytesToConvert) written +=
lazySend.writeTo(channel, written, bytesToConvert - written);
+ // Use bytesToConvert as remaining to avoid truncating batches
when V1 is larger than V2 (e.g. zlib-ng)
+ while (written < bytesToConvert) written +=
lazySend.writeTo(channel, written, bytesToConvert);
try (FileRecords convertedRecords =
FileRecords.open(outputFile, true, written, false)) {
convertedRecordsBuffer =
ByteBuffer.allocate(convertedRecords.sizeInBytes());
convertedRecords.readInto(convertedRecordsBuffer, 0);