This is an automated email from the ASF dual-hosted git repository.

aherbert pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/commons-codec.git

commit 34c9feb3c79e6d4866e30db59b593c9d66229f61
Author: Alex Herbert <aherb...@apache.org>
AuthorDate: Wed Jul 15 13:10:39 2020 +0100

    Use ThreadLocalRandom.current()
---
 src/test/java/org/apache/commons/codec/binary/HexTest.java | 12 +++++-------
 1 file changed, 5 insertions(+), 7 deletions(-)

diff --git a/src/test/java/org/apache/commons/codec/binary/HexTest.java 
b/src/test/java/org/apache/commons/codec/binary/HexTest.java
index ba6ee4b..7f0fc1c 100644
--- a/src/test/java/org/apache/commons/codec/binary/HexTest.java
+++ b/src/test/java/org/apache/commons/codec/binary/HexTest.java
@@ -30,7 +30,7 @@ import java.nio.charset.StandardCharsets;
 import java.nio.charset.UnsupportedCharsetException;
 import java.util.Arrays;
 import java.util.Random;
-
+import java.util.concurrent.ThreadLocalRandom;
 import org.apache.commons.codec.DecoderException;
 import org.apache.commons.codec.EncoderException;
 import org.junit.Assert;
@@ -422,12 +422,11 @@ public class HexTest {
 
     @Test
     public void testEncodeDecodeHexCharArrayRandom() throws DecoderException, 
EncoderException {
-        final Random random = new Random();
 
         final Hex hex = new Hex();
         for (int i = 5; i > 0; i--) {
-            final byte[] data = new byte[random.nextInt(10000) + 1];
-            random.nextBytes(data);
+            final byte[] data = new 
byte[ThreadLocalRandom.current().nextInt(10000) + 1];
+            ThreadLocalRandom.current().nextBytes(data);
 
             // static API
             final char[] encodedChars = Hex.encodeHex(data);
@@ -455,10 +454,9 @@ public class HexTest {
 
     @Test
     public void testEncodeDecodeHexCharArrayRandomToOutput() throws 
DecoderException, EncoderException {
-        final Random random = new Random();
         for (int i = 5; i > 0; i--) {
-            final byte[] data = new byte[random.nextInt(10000) + 1];
-            random.nextBytes(data);
+            final byte[] data = new 
byte[ThreadLocalRandom.current().nextInt(10000) + 1];
+            ThreadLocalRandom.current().nextBytes(data);
 
             // lower-case
             final char[] lowerEncodedChars = new char[data.length * 2];

Reply via email to