You are viewing a plain text version of this content. The canonical link for it is here.
Posted to jira@kafka.apache.org by GitBox <gi...@apache.org> on 2021/01/26 19:09:10 UTC
[GitHub] [kafka] chia7712 commented on a change in pull request #9970: Kafka-12233: `FileRecords.writeTo` set length incorrectly
chia7712 commented on a change in pull request #9970:
URL: https://github.com/apache/kafka/pull/9970#discussion_r564762299
##########
File path: clients/src/main/java/org/apache/kafka/common/record/FileRecords.java
##########
@@ -278,7 +278,7 @@ public long writeTo(TransferableChannel destChannel, long offset, int length) th
file.getAbsolutePath(), oldSize, newSize));
long position = start + offset;
- int count = Math.min(length, oldSize);
+ long count = Math.min(length, oldSize - offset);
Review comment:
> Perhaps what we could do is to throw an IllegalStateException if the file channel doesn't have enough bytes left. This will cause the socket channel to be closed and the Selector to log a warning.
Please update docs for related ```writeTo``` methods if we want to apply this behavior. The current code use return value to calculate the length for next write. The return value gets redundant since the number of transferred data is always equal to expected length (it throws exception when there is no enough bytes left).
----------------------------------------------------------------
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.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org