diff --git a/Common/src/main/java/com/tabnineCommon/general/TopicBasedState.kt b/Common/src/main/java/com/tabnineCommon/general/TopicBasedState.kt index 84e14b6b..b302f3b3 100644 --- a/Common/src/main/java/com/tabnineCommon/general/TopicBasedState.kt +++ b/Common/src/main/java/com/tabnineCommon/general/TopicBasedState.kt @@ -3,14 +3,18 @@ package com.tabnineCommon.general import com.intellij.openapi.Disposable import com.intellij.openapi.application.ApplicationManager import com.intellij.util.messages.Topic -import java.util.Optional +import java.util.* import java.util.concurrent.atomic.AtomicBoolean import java.util.concurrent.locks.Lock import java.util.concurrent.locks.ReadWriteLock import java.util.concurrent.locks.ReentrantReadWriteLock import java.util.function.Consumer -open class TopicBasedState>(private val topic: Topic, private var value: T? = null) { +open class TopicBasedState>( + private val topic: Topic, + @Volatile + private var value: T? = null +) { private val rwLock: ReadWriteLock = ReentrantReadWriteLock() private val hasChanged = AtomicBoolean(false) @@ -39,7 +43,8 @@ open class TopicBasedState>(private val topic: Topic, priv subscription.accept(value!!) } - ApplicationManager.getApplication().messageBus.connect(parent).subscribe(topic, subscription) + ApplicationManager.getApplication().messageBus.connect(parent) + .subscribe(topic, subscription) } }