File tree Expand file tree Collapse file tree 3 files changed +11
-11
lines changed
src/main/java/com/fasterxml/uuid/impl Expand file tree Collapse file tree 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)
131131 * Contributed #73: Add `Generators.defaultTimeBasedGenerator()` to use "default"
132132 interface address for time/based UUIDs
133133 [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 775.0.0 (not yet released)
88
99#53: Increase JDK baseline to JDK 8
10+ #85: Fix `LazyRandom` for native code generation tools
11+ (contributed by @Maia-Everett)
1012
11134.3.0 (12-Sep-2023)
1214
Original file line number Diff line number Diff line change 66 * Trivial helper class that uses class loading as synchronization
77 * mechanism for lazy instantiation of the shared secure random
88 * instance.
9+ *<p>
10+ * Since 5.0 has been lazily created to avoid issues with native-generation
11+ * tools like Graal.
912 */
1013public final class LazyRandom
1114{
1215 private static final Object lock = new Object ();
1316 private static volatile SecureRandom shared ;
1417
1518 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-
2419 synchronized (lock ) {
25- result = shared ;
26-
20+ SecureRandom result = shared ;
2721 if (result == null ) {
28- result = shared = new SecureRandom ();
22+ shared = result = new SecureRandom ();
2923 }
3024
3125 return result ;
You can’t perform that action at this time.
0 commit comments