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

AbstractSplittableWithBrineGenerator does not create a random salt

    XMLWordPrintable

    Details

    • Type: CSR
    • Status: Closed
    • Priority: P3
    • Resolution: Approved
    • Fix Version/s: 17-pool, 18
    • Component/s: core-libs
    • Labels:
      None
    • Subcomponent:
    • Compatibility Kind:
      behavioral
    • Compatibility Risk:
      low
    • Compatibility Risk Description:
      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.
    • Interface Kind:
      Java API
    • Scope:
      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

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

                Dates

                Created:
                Updated:
                Resolved: