adoroszlai commented on code in PR #6041:
URL: https://github.com/apache/ozone/pull/6041#discussion_r1460491851


##########
hadoop-hdds/client/src/test/java/org/apache/hadoop/ozone/client/io/TestECBlockReconstructedStripeInputStream.java:
##########
@@ -41,7 +41,7 @@
 import java.util.HashSet;
 import java.util.List;
 import java.util.Map;
-import java.util.Random;
+import org.apache.commons.lang3.RandomUtils;

Review Comment:
   nit: please try to keep alphabetical order, move to:
   
   
https://github.com/apache/ozone/blob/a7d4b0679abf20c537e441eb6675a6ffd2964f7e/hadoop-hdds/client/src/test/java/org/apache/hadoop/ozone/client/io/TestECBlockReconstructedStripeInputStream.java#L20-L21
   
   (the same minor issue applies to some of the other files)



##########
hadoop-hdds/common/src/test/java/org/apache/hadoop/ozone/common/TestChecksumByteBuffer.java:
##########
@@ -59,11 +59,10 @@ void testCorrectness() {
 
       checkBytes("hello world!".getBytes(StandardCharsets.UTF_8));
 
-      final Random random = new Random();
       final byte[] bytes = new byte[1 << 10];
       for (int i = 0; i < 1000; i++) {
-        random.nextBytes(bytes);
-        checkBytes(bytes, random.nextInt(bytes.length));
+        RandomUtils.nextBytes(bytes.length);
+        checkBytes(bytes, RandomUtils.nextInt(0, bytes.length));

Review Comment:
   `nextBytes` returns the byte array, which is ignored here.  So `bytes` is 
the same in each iteration instead of having random content.
   
   Since this results in a new array in each iteration, we can remove the 
original `bytes` array.
   
   ```java
         final int len = 1 << 10;
         for (int i = 0; i < 1000; i++) {
           checkBytes(RandomUtils.nextBytes(len), RandomUtils.nextInt(0, len));
         }
   ```



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


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to