mirror of
https://github.com/github/codeql.git
synced 2026-04-30 11:15:13 +02:00
Add support for java.util.concurrent.ThreadLocalRandom
This commit is contained in:
@@ -1,4 +1,6 @@
|
||||
| Test.java:9:5:9:25 | abs(...) | Incorrect computation of abs of signed integral random value. |
|
||||
| Test.java:10:5:10:26 | abs(...) | Incorrect computation of abs of signed integral random value. |
|
||||
| Test.java:13:5:13:35 | abs(...) | Incorrect computation of abs of signed integral random value. |
|
||||
| Test.java:14:5:14:36 | abs(...) | Incorrect computation of abs of signed integral random value. |
|
||||
| Test.java:10:5:10:25 | abs(...) | Incorrect computation of abs of signed integral random value. |
|
||||
| Test.java:11:5:11:26 | abs(...) | Incorrect computation of abs of signed integral random value. |
|
||||
| Test.java:14:5:14:35 | abs(...) | Incorrect computation of abs of signed integral random value. |
|
||||
| Test.java:15:5:15:36 | abs(...) | Incorrect computation of abs of signed integral random value. |
|
||||
| Test.java:20:5:20:27 | abs(...) | Incorrect computation of abs of signed integral random value. |
|
||||
| Test.java:21:5:21:28 | abs(...) | Incorrect computation of abs of signed integral random value. |
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import java.util.Random;
|
||||
import java.util.concurrent.ThreadLocalRandom;
|
||||
import org.apache.commons.lang3.RandomUtils;
|
||||
|
||||
public class Test {
|
||||
@@ -15,6 +16,14 @@ public class Test {
|
||||
Math.abs(RandomUtils.nextInt(1, 10)); // GOOD: random value already has a restricted range
|
||||
Math.abs(RandomUtils.nextLong(1, 10)); // GOOD: random value already has a restricted range
|
||||
|
||||
ThreadLocalRandom tlr = ThreadLocalRandom.current();
|
||||
Math.abs(tlr.nextInt());
|
||||
Math.abs(tlr.nextLong());
|
||||
Math.abs(tlr.nextInt(10)); // GOOD: random value already has a restricted range
|
||||
Math.abs(tlr.nextLong(10)); // GOOD: random value already has a restricted range
|
||||
Math.abs(tlr.nextInt(1, 10)); // GOOD: random value already has a restricted range
|
||||
Math.abs(tlr.nextLong(1, 10)); // GOOD: random value already has a restricted range
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user