mirror of
https://github.com/openjdk/jdk.git
synced 2026-08-03 06:35:31 +00:00
8387722: The race during initialization or lazy constants in and Map/Set
Reviewed-by: jvernee
This commit is contained in:
parent
97544c7ede
commit
3412d4c0dd
@ -675,6 +675,12 @@ final class LazyCollections {
|
||||
final long offset = offsetFor(index);
|
||||
final Object mutex = mutexes.acquireMutex(offset);
|
||||
if (mutex == null) {
|
||||
// There might be a race where the value is already computed and
|
||||
// the mutex is cleared, so we need to re-check the value again
|
||||
final T t = (T) UNSAFE.getReferenceAcquire(array, offset);
|
||||
if (t != null) {
|
||||
return t;
|
||||
}
|
||||
throwIfPreviousException(index, throwables, input);
|
||||
// There must be an exception
|
||||
throw cannotReachHere(functionHolder, input);
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user