junrao commented on code in PR #23737:
URL: https://github.com/apache/kafka/pull/23737#discussion_r4275602478


##########
clients/src/test/java/org/apache/kafka/common/record/internal/FileRecordsTest.java:
##########
@@ -240,6 +241,70 @@ public void testRead() {
         assertEquals(Collections.singletonList(second), batches(read), "Read a 
single message starting from the second message");
     }
 
+    @Test
+    public void testReadIntoStopsAtEndOfSlice() throws IOException {
+        try (FileRecords fileRecords = createFileRecords(values)) {

Review Comment:
   testReadIntoStopsAtEndOfSlice, testReadIntoAtEndOfRecordsReadsNothing and 
testReadIntoWithPositionOutsideRecords can just use the fileRecords created in 
setup().



##########
raft/src/main/java/org/apache/kafka/raft/internals/RecordsIterator.java:
##########
@@ -136,9 +136,10 @@ private MemoryRecords createMemoryRecords(FileRecords 
fileRecords) {
 
         MemoryRecords memoryRecords = readFileRecords(fileRecords, buffer);
 
-        // firstBatchSize() is always non-null because the minimum buffer is 
HEADER_SIZE_UP_TO_MAGIC.
-        int firstBatchSize = memoryRecords.firstBatchSize();
-        if (firstBatchSize <= buffer.remaining()) {
+        Integer firstBatchSize = memoryRecords.firstBatchSize();

Review Comment:
   We can use firstBatchSize in line 151 now.



-- 
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]

Reply via email to