mimaison commented on code in PR #22604:
URL: https://github.com/apache/kafka/pull/22604#discussion_r3450763501


##########
raft/src/testFixtures/java/org/apache/kafka/common/record/internal/ArbitraryMemoryRecords.java:
##########
@@ -16,24 +16,31 @@
  */
 package org.apache.kafka.common.record.internal;
 
-import net.jqwik.api.Arbitraries;
-import net.jqwik.api.Arbitrary;
-import net.jqwik.api.ArbitrarySupplier;
+import org.junit.jupiter.api.function.ThrowingConsumer;
 
 import java.nio.ByteBuffer;
+import java.util.Arrays;
 import java.util.Random;
 
-public final class ArbitraryMemoryRecords implements 
ArbitrarySupplier<MemoryRecords> {
-    @Override
-    public Arbitrary<MemoryRecords> get() {
-        return 
Arbitraries.randomValue(ArbitraryMemoryRecords::buildRandomRecords);
-    }
+import static org.junit.jupiter.api.Assertions.fail;
+
+public final class ArbitraryMemoryRecords {
 
-    private static MemoryRecords buildRandomRecords(Random random) {
-        int size = random.nextInt(128) + 1;
-        byte[] bytes = new byte[size];
-        random.nextBytes(bytes);
+    private ArbitraryMemoryRecords() {}
 
-        return MemoryRecords.readableRecords(ByteBuffer.wrap(bytes));
+    public static void forRandomRecords(int tries, 
ThrowingConsumer<MemoryRecords> test) {
+        for (int i = 0; i < tries; i++) {
+            long seed = System.nanoTime() + i;
+            Random random = new Random(seed);
+            int size = random.nextInt(128) + 1;
+            byte[] bytes = new byte[size];
+            random.nextBytes(bytes);
+            MemoryRecords records = 
MemoryRecords.readableRecords(ByteBuffer.wrap(bytes));
+            try {

Review Comment:
   Yes that's a bit cleaner. I've used that pattern in the other calls as well 
except in `forTopicSuffixesRandom()` where `topic` is not `final` so it would 
cause other changes.



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