You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by ac...@apache.org on 2021/02/15 07:03:27 UTC

[camel] 02/02: CAMEL-16193 - Use SecureRandom instead of Random - Camel-FTP

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

acosentino pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/camel.git

commit f3b688c76ff9ac60c91884e053e2ca134f41774a
Author: Andrea Cosentino <an...@gmail.com>
AuthorDate: Mon Feb 15 08:02:50 2021 +0100

    CAMEL-16193 - Use SecureRandom instead of Random - Camel-FTP
---
 .../camel/component/file/remote/FtpConsumerAsyncStressTest.java       | 4 ++--
 .../camel/component/file/remote/FtpProducerMoveExistingTest.java      | 4 ++--
 2 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FtpConsumerAsyncStressTest.java b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FtpConsumerAsyncStressTest.java
index 5e74774..6dcf57c 100644
--- a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FtpConsumerAsyncStressTest.java
+++ b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FtpConsumerAsyncStressTest.java
@@ -16,7 +16,7 @@
  */
 package org.apache.camel.component.file.remote;
 
-import java.util.Random;
+import java.security.SecureRandom;
 
 import org.apache.camel.Exchange;
 import org.apache.camel.Processor;
@@ -65,7 +65,7 @@ public class FtpConsumerAsyncStressTest extends FtpServerTestSupport {
                 from(getFtpUrl()).threads(10).process(new Processor() {
                     public void process(Exchange exchange) throws Exception {
                         // simulate some work with random time to complete
-                        Random ran = new Random();
+                        SecureRandom ran = new SecureRandom();
                         int delay = ran.nextInt(500) + 10;
                         Thread.sleep(delay);
                     }
diff --git a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FtpProducerMoveExistingTest.java b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FtpProducerMoveExistingTest.java
index 0275732..57b732e 100644
--- a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FtpProducerMoveExistingTest.java
+++ b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FtpProducerMoveExistingTest.java
@@ -18,9 +18,9 @@ package org.apache.camel.component.file.remote;
 
 import java.io.File;
 import java.io.FilenameFilter;
+import java.security.SecureRandom;
 import java.text.SimpleDateFormat;
 import java.util.Date;
-import java.util.Random;
 
 import org.apache.camel.CamelExecutionException;
 import org.apache.camel.Exchange;
@@ -249,7 +249,7 @@ public class FtpProducerMoveExistingTest extends FtpServerTestSupport {
     private String generateRandomString(int targetStringLength) {
         int leftLimit = 97; // letter 'a'
         int rightLimit = 122; // letter 'z'
-        Random random = new Random();
+        SecureRandom random = new SecureRandom();
         StringBuilder buffer = new StringBuilder(targetStringLength);
         for (int i = 0; i < targetStringLength; i++) {
             int randomLimitedInt = leftLimit + (int) (random.nextFloat() * (rightLimit - leftLimit + 1));