RFR 8157318: ThreadedSeedGenerator uses System.currentTimeMillis and stops generating when time is set back
Xuelei Fan
xuelei.fan at oracle.com
Wed Jun 15 12:07:31 UTC 2016
I'm not sure I understand the while loop. But this update looks fine to
me as it does not change the logic of the code except to use elapsed time.
Xuelei
On 6/15/2016 11:12 AM, Wang Weijun wrote:
> Please take a review on the patch
>
> diff --git a/src/java.base/share/classes/sun/security/provider/SeedGenerator.java b/src/java.base/share/classes/sun/security/provider/SeedGenerator.java
> --- a/src/java.base/share/classes/sun/security/provider/SeedGenerator.java
> +++ b/src/java.base/share/classes/sun/security/provider/SeedGenerator.java
> @@ -354,8 +354,8 @@
> // We wait 250milli quanta, so the minimum wait time
> // cannot be under 250milli.
> int latch = 0;
> - long l = System.currentTimeMillis() + 250;
> - while (System.currentTimeMillis() < l) {
> + long l = System.nanoTime() + 250000000;
> + while (System.nanoTime() < l) {
> synchronized(this){};
> latch++;
> }
>
> nanoTime() is for elapsed time and should be used here.
>
> Thanks
> Max
>
More information about the security-dev
mailing list