Use double-checked locking in some reflection internals
Note that `volatile` is not needed because in both cases we initialize an object with a final field, which is subject to safe initialization.
This commit is contained in:
@@ -86,10 +86,8 @@ private object Java8RepeatableContainerLoader {
|
||||
}
|
||||
|
||||
fun loadRepeatableContainer(klass: Class<out Annotation>): Class<out Annotation>? {
|
||||
var cache = cache
|
||||
if (cache == null) {
|
||||
cache = buildCache()
|
||||
this.cache = cache
|
||||
val cache = cache ?: synchronized(this) {
|
||||
cache ?: buildCache().also { cache = it }
|
||||
}
|
||||
|
||||
val repeatableClass = cache.repeatableClass ?: return null
|
||||
|
||||
Reference in New Issue
Block a user