From ce627ce81c16bf3e2ccd081bd0f5cbcf6067db38 Mon Sep 17 00:00:00 2001 From: Vladimir Krivosheev Date: Thu, 11 Apr 2019 21:07:31 +0200 Subject: [PATCH] check that changed storages list is not empty --- .../src/StorageVirtualFileTracker.kt | 9 +++++++-- .../src/StoreReloadManagerImpl.kt | 4 ++++ 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/platform/configuration-store-impl/src/StorageVirtualFileTracker.kt b/platform/configuration-store-impl/src/StorageVirtualFileTracker.kt index 9d7baa90b422..10673490a372 100644 --- a/platform/configuration-store-impl/src/StorageVirtualFileTracker.kt +++ b/platform/configuration-store-impl/src/StorageVirtualFileTracker.kt @@ -53,7 +53,7 @@ class StorageVirtualFileTracker(private val messageBus: MessageBus) { private fun addVfsChangesListener() { messageBus.connect().subscribe(VirtualFileManager.VFS_CHANGES, object : BulkFileListener { override fun after(events: MutableList) { - val storageEvents = LinkedHashMap>() + var storageEvents: LinkedHashMap>? = null eventLoop@ for (event in events) { var storage: StateStorage? if (event is VFilePropertyChangeEvent && VirtualFile.PROP_NAME == event.propertyName) { @@ -110,11 +110,16 @@ class StorageVirtualFileTracker(private val messageBus: MessageBus) { if (isFireStorageFileChangedEvent(event)) { val componentManager = storage.storageManager.componentManager!! + if (storageEvents == null) { + storageEvents = LinkedHashMap() + } storageEvents.getOrPut(componentManager) { LinkedHashSet() }.add(storage) } } - StoreReloadManager.getInstance().storageFilesChanged(storageEvents) + if (storageEvents != null) { + StoreReloadManager.getInstance().storageFilesChanged(storageEvents) + } } }) } diff --git a/platform/configuration-store-impl/src/StoreReloadManagerImpl.kt b/platform/configuration-store-impl/src/StoreReloadManagerImpl.kt index 33fbd8c685d8..a9305b67c7a4 100644 --- a/platform/configuration-store-impl/src/StoreReloadManagerImpl.kt +++ b/platform/configuration-store-impl/src/StoreReloadManagerImpl.kt @@ -158,6 +158,10 @@ internal class StoreReloadManagerImpl : StoreReloadManager, Disposable { } override fun storageFilesChanged(componentManagerToStorages: Map>) { + if (componentManagerToStorages.isEmpty()) { + return + } + if (LOG.isDebugEnabled) { LOG.debug("[RELOAD] registering to reload: ${componentManagerToStorages.map { "${it.key}: ${it.value.joinToString()}" }.joinToString("\n")}", Exception()) }