RFR: JDK-8273162 AbstractSplittableWithBrineGenerator does not create a random salt

Jim Laskey jlaskey at openjdk.java.net
Thu Sep 9 18:07:18 UTC 2021


RandomSupport.AbstractSplittableWithBrineGenerator. makeSplitsSpliterator is intending to create a salt from a random long. The salt should have random letters of size 4 for each consecutive 4 bits and then the last 4 bits as ff, i.e. all bits set. 

However the loop is never executed, the random bits are not used and the salt is always the same. 

This condition is false on the first execution: 

  long multiplier = (1L << SALT_SHIFT) - 1; 
  long salt = multiplier << (64 - SALT_SHIFT); 
  while ((salt & multiplier) != 0) { 


This can be corrected by changing: 

  while ((salt & multiplier) != 0) { 

to 

  while ((salt & multiplier) == 0) {

-------------

Commit messages:
 - Correct the loop condition

Changes: https://git.openjdk.java.net/jdk/pull/5449/files
 Webrev: https://webrevs.openjdk.java.net/?repo=jdk&pr=5449&range=00
  Issue: https://bugs.openjdk.java.net/browse/JDK-8273162
  Stats: 1 line in 1 file changed: 0 ins; 0 del; 1 mod
  Patch: https://git.openjdk.java.net/jdk/pull/5449.diff
  Fetch: git fetch https://git.openjdk.java.net/jdk pull/5449/head:pull/5449

PR: https://git.openjdk.java.net/jdk/pull/5449


More information about the core-libs-dev mailing list