chia7712 commented on code in PR #21577:
URL: https://github.com/apache/kafka/pull/21577#discussion_r2894143024


##########
storage/src/main/java/org/apache/kafka/storage/internals/log/TransactionIndex.java:
##########
@@ -216,22 +221,19 @@ private FileChannel channelOrNull() {
     }
 
     private Iterable<AbortedTxnWithPosition> iterable() {
-        return iterable(() -> ByteBuffer.allocate(AbortedTxn.TOTAL_SIZE));
-    }
-
-    private Iterable<AbortedTxnWithPosition> iterable(Supplier<ByteBuffer> 
allocate) {
         FileChannel channel = channelOrNull();
         if (channel == null)
             return List.of();
 
+        ByteBuffer buffer = ByteBuffer.allocate(ABORTED_TXN_RECORD_SIZE);
         PrimitiveRef.IntRef position = PrimitiveRef.ofInt(0);
 
         return () -> new Iterator<>() {

Review Comment:
   I just noticed a potential bug with this `Iterable`, It does not return 
independent `Iterator` instances. Since they all share the same `buffer` and 
`position`, this can lead to a corrupted state. Could you please fix this and 
add some tests?



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