Skip to content

Commit 7d10183

Browse files
authored
Merge pull request #5 from unidev-platform/randoms-fix
Fixed randoms sleep calculations
2 parents af528a2 + 027f997 commit 7d10183

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

unidev-common/src/main/java/com/unidev/platform/Randoms.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -74,27 +74,27 @@ public <T> T randomValue(T... array) {
7474
*/
7575
public String randomValue(String dictionary, int minLength, int maxLength, boolean firstCharUpperCase) {
7676
int count = minLength + random.nextInt(maxLength - minLength);
77-
String result = "";
77+
StringBuilder result = new StringBuilder();
7878
for (int i = 0; i < count; i++) {
7979
int id = random.nextInt(dictionary.length());
8080
Character c = dictionary.charAt(id);
8181
if (i == 0 && firstCharUpperCase) {
8282
c = Character.toUpperCase(c);
8383
}
84-
result += c;
84+
result.append(c);
8585
}
86-
return result;
86+
return result.toString();
8787
}
8888

8989
/**
9090
* Get random sleep value in seconds
9191
* @return Selected sleep value
9292
*/
93-
public int randomSleepValue(int min, int max) {
93+
public long randomSleepValue(long min, long max) {
9494
if (min == max) {
9595
return min;
9696
}
97-
int sleep = 1000 + (1000 * (min + random.nextInt(max - min)));
97+
long sleep = 1000 + (1000 * (min + random.nextInt((int) (max - min))));
9898
log.debug("Selected sleep value {}", sleep);
9999
return sleep;
100100
}

0 commit comments

Comments
 (0)