-
CSR
-
Resolution: Approved
-
P3
-
None
-
behavioral
-
low
-
The expected result is random. The change will produce better randomness. If an application expects a specific sequence produced from a specific seed then they may experience issues. However, this is only likely in testing environments.
-
Java API
-
Implementation
Summary
The salting function for random spliterators produces a constant (same) result.
Problem
The implementation has a "not equals" condition in the iteration portion of the algorithm when it should be "equals".
Solution
Correct the condition.
Specification
diff --git a/src/java.base/share/classes/jdk/internal/util/random/RandomSupport.java b/src/java.base/share/classes/jdk/internal/util/random/RandomSupport.java
index 8f5ea82ed1c..1d64432979d 100644
--- a/src/java.base/share/classes/jdk/internal/util/random/RandomSupport.java
+++ b/src/java.base/share/classes/jdk/internal/util/random/RandomSupport.java
@@ -2380,7 +2380,7 @@ public class RandomSupport {
long bits = nextLong();
long multiplier = (1L << SALT_SHIFT) - 1;
long salt = multiplier << (64 - SALT_SHIFT);
- while ((salt & multiplier) != 0) {
+ while ((salt & multiplier) == 0) {
long digit = Math.multiplyHigh(bits, multiplier);
salt = (salt >>> SALT_SHIFT) | (digit << (64 - SALT_SHIFT));
bits *= multiplier;
- csr of
-
JDK-8273162 AbstractSplittableWithBrineGenerator does not create a random salt
-
- Closed
-