File tree 3 files changed +11
-11
lines changed
src/main/java/com/fasterxml/uuid/impl
3 files changed +11
-11
lines changed Original file line number Diff line number Diff line change @@ -131,3 +131,7 @@ Paul Galbraith (pgalbraith@github)
131
131
* Contributed #73: Add `Generators.defaultTimeBasedGenerator()` to use "default"
132
132
interface address for time/based UUIDs
133
133
[4.2.0]
134
+
135
+ Maia Everett (Maia-Everett@github)
136
+ * Contributed #85: Fix `LazyRandom` for native code generation tools
137
+ [5.0.0]
Original file line number Diff line number Diff line change 7
7
5.0.0 (not yet released)
8
8
9
9
#53: Increase JDK baseline to JDK 8
10
+ #85: Fix `LazyRandom` for native code generation tools
11
+ (contributed by @Maia-Everett)
10
12
11
13
4.3.0 (12-Sep-2023)
12
14
Original file line number Diff line number Diff line change 6
6
* Trivial helper class that uses class loading as synchronization
7
7
* mechanism for lazy instantiation of the shared secure random
8
8
* instance.
9
+ *<p>
10
+ * Since 5.0 has been lazily created to avoid issues with native-generation
11
+ * tools like Graal.
9
12
*/
10
13
public final class LazyRandom
11
14
{
12
15
private static final Object lock = new Object ();
13
16
private static volatile SecureRandom shared ;
14
17
15
18
public static SecureRandom sharedSecureRandom () {
16
- // Double check lazy initialization idiom (Effective Java 3rd edition item 11.6)
17
- // Use so that native code generation tools do not detect a SecureRandom instance in a static final field.
18
- SecureRandom result = shared ;
19
-
20
- if (result != null ) {
21
- return result ;
22
- }
23
-
24
19
synchronized (lock ) {
25
- result = shared ;
26
-
20
+ SecureRandom result = shared ;
27
21
if (result == null ) {
28
- result = shared = new SecureRandom ();
22
+ shared = result = new SecureRandom ();
29
23
}
30
24
31
25
return result ;
You can’t perform that action at this time.
0 commit comments