Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8273183

AbstractSplittableWithBrineGenerator does not create a random salt

    XMLWordPrintable

Details

    • CSR
    • Resolution: Approved
    • P3
    • 17-pool, 18
    • core-libs
    • 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

    Description

      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;

      Attachments

        Issue Links

          Activity

            People

              jlaskey Jim Laskey
              webbuggrp Webbug Group
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: