Details
-
Improvement
-
Status: Resolved
-
Minor
-
Resolution: Fixed
-
None
-
None
-
None
Description
As of Kafka 3.7.0, SslTransportLayer.write(ByteBuffer[], int, int) is implemented like below:
public long write(ByteBuffer[] srcs, int offset, int length) throws IOException { ... int i = offset; while (i < length) { if (srcs[i].hasRemaining() || hasPendingWrites()) { ....
The loop index starts at `offset` and ends with `length`.
However this isn't correct because end-index should be `offset + length`.
Let's say we have the array of ByteBuffer with length = 5 and try calling this method with offset = 3, length = 1.
In current code, `write(srcs, 3, 1)` doesn't attempt any write because the loop condition is immediately false.
For now, seems this method is only called with args offset = 0, length = srcs.length in Kafka code base so not causing any problem though, we should fix this because this could introduce subtle bug if use this method with different args in the future.
Attachments
Issue Links
- links to