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

SecureRandom#nextInt(29) does not return

XMLWordPrintable

      ADDITIONAL SYSTEM INFORMATION :
      Distributor ID: Ubuntu
      Description: Ubuntu 18.04.4 LTS
      Release: 18.04
      Codename: bionic

      openjdk version "11.0.6" 2020-01-14
      OpenJDK Runtime Environment (build 11.0.6+10-post-Ubuntu-1ubuntu118.04.1)
      OpenJDK 64-Bit Server VM (build 11.0.6+10-post-Ubuntu-1ubuntu118.04.1, mixed mode, sharing)


      A DESCRIPTION OF THE PROBLEM :
      SecureRandom#nextInt(29) does not return in simple program.

      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      import java.security.SecureRandom;

      public class Example
      {
          public static void main(String[] args) throws Exception
          {
              SecureRandom rand = SecureRandom.getInstanceStrong();

              System.out.println("about to call nextInt()");
              int randInt = rand.nextInt(29);
              System.out.println("got " + randInt);
          }
      }

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      Two print lines.
      ACTUAL -
      ubuntu@ip-172-31-5-52:~$ java Example
      about to call nextInt()

      (program hangs with no further output)

      ---------- BEGIN SOURCE ----------
      import java.security.SecureRandom;

      public class Example
      {
          public static void main(String[] args) throws Exception
          {
              SecureRandom rand = SecureRandom.getInstanceStrong();

              System.out.println("about to call nextInt()");
              int randInt = rand.nextInt(29);
              System.out.println("got " + randInt);
          }
      }
      ---------- END SOURCE ----------

      CUSTOMER SUBMITTED WORKAROUND :
      Executes fine on Windows.

      FREQUENCY : always


            wetmore Bradford Wetmore
            webbuggrp Webbug Group
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved: