cheeeee commented on code in PR #23832:
URL: https://github.com/apache/kafka/pull/23832#discussion_r4300114137
##########
clients/src/main/java/org/apache/kafka/common/network/SslTransportLayer.java:
##########
@@ -1038,10 +1038,16 @@ public long transferFrom(FileChannel fileChannel, long
position, long count) thr
int bytesRemaining = totalBytesToWrite - totalBytesWritten;
if (bytesRemaining < fileChannelBuffer.limit())
fileChannelBuffer.limit(bytesRemaining);
- int bytesRead = fileChannel.read(fileChannelBuffer, pos);
+ int bytesRead;
+ try {
+ bytesRead = fileChannel.read(fileChannelBuffer, pos);
+ } finally {
Review Comment:
Done: `transferFrom` now rethrows. I kept the flip, since a read that
returns -1, e.g. after a concurrent truncation, throws nothing, and without the
flip the buffer would still look full of the previous read on the next call.
`FileRecords.writeTo` fails that next call with its truncation check unless the
file has grown back past the slice by then, but `transferFrom` should not rely
on its caller for that; `testTransferFromDoesNotSendStaleBytesAtEndOfFile`
covers it.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]