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

Files.createTempDirectory fails: Unexpected CryptoAPI failure generating seed

XMLWordPrintable

      A DESCRIPTION OF THE PROBLEM :
      An attempt to create temporary directory (or file) sometimes fails with following error:

      java.lang.InternalError: Unexpected CryptoAPI failure generating seed
      at java.base/sun.security.provider.NativeSeedGenerator.getSeedBytes(NativeSeedGenerator.java:62)
      at java.base/sun.security.provider.SeedGenerator.generateSeed(SeedGenerator.java:144)
      at java.base/sun.security.provider.AbstractDrbg.lambda$static$0(AbstractDrbg.java:524)
      at java.base/sun.security.provider.AbstractDrbg.getEntropyInput(AbstractDrbg.java:507)
      at java.base/sun.security.provider.AbstractDrbg.getEntropyInput(AbstractDrbg.java:494)
      at java.base/sun.security.provider.AbstractDrbg.instantiateIfNecessary(AbstractDrbg.java:696)
      at java.base/sun.security.provider.AbstractDrbg.engineNextBytes(AbstractDrbg.java:378)
      at java.base/sun.security.provider.AbstractDrbg.engineNextBytes(AbstractDrbg.java:334)
      at java.base/sun.security.provider.AbstractDrbg$SeederHolder.lambda$static$0(AbstractDrbg.java:558)
      at java.base/sun.security.provider.AbstractDrbg.getEntropyInput(AbstractDrbg.java:507)
      at java.base/sun.security.provider.AbstractDrbg.getEntropyInput(AbstractDrbg.java:494)
      at java.base/sun.security.provider.AbstractDrbg.instantiateIfNecessary(AbstractDrbg.java:696)
      at java.base/sun.security.provider.AbstractDrbg.engineNextBytes(AbstractDrbg.java:378)
      at java.base/sun.security.provider.AbstractDrbg.engineNextBytes(AbstractDrbg.java:334)
      at java.base/sun.security.provider.DRBG.engineNextBytes(DRBG.java:235)
      at java.base/java.security.SecureRandom.nextBytes(SecureRandom.java:758)
      at java.base/java.security.SecureRandom.next(SecureRandom.java:815)
      at java.base/java.util.Random.nextLong(Random.java:357)
      at java.base/java.nio.file.TempFileHelper.generatePath(TempFileHelper.java:55)
      at java.base/java.nio.file.TempFileHelper.create(TempFileHelper.java:125)
      at java.base/java.nio.file.TempFileHelper.createTempDirectory(TempFileHelper.java:171)
      at java.base/java.nio.file.Files.createTempDirectory(Files.java:1017)


      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      The failure happens from time to time on our CI servers during testing.

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      Temporary file or directory should not fail due to failure to obtain secure random. At least in our case there is no need to use SecureRandom at all. We are ok with unsecure random, current time as a random number or just sequental numbers like 1, 2, 3 etc to make temporary path unique.
      ACTUAL -
      Sporadical failure to create temporary directory or file.

      CUSTOMER SUBMITTED WORKAROUND :
      There isn't known workaround. We tried to reorder security providers in jre/conf/security/java.security file: placed SunMSCAPI before SUN, but this did not help.

      FREQUENCY : occasionally


            pkoppula Prasadarao Koppula
            webbuggrp Webbug Group
            Votes:
            0 Vote for this issue
            Watchers:
            5 Start watching this issue

              Created:
              Updated: