diff --git a/build-common/src/org/jetbrains/kotlin/incremental/storage/BasicMap.kt b/build-common/src/org/jetbrains/kotlin/incremental/storage/BasicMap.kt index 36ed73d9b01..b935ef3962c 100644 --- a/build-common/src/org/jetbrains/kotlin/incremental/storage/BasicMap.kt +++ b/build-common/src/org/jetbrains/kotlin/incremental/storage/BasicMap.kt @@ -47,7 +47,8 @@ abstract class BasicMap, V>( storage.flush(memoryCachesOnly) } - fun close() { + // avoid unsynchronized close + internal fun close() { storage.close() } diff --git a/build-common/src/org/jetbrains/kotlin/incremental/storage/CachingLazyStorage.kt b/build-common/src/org/jetbrains/kotlin/incremental/storage/CachingLazyStorage.kt index 7e4a25c2ada..090870a9389 100644 --- a/build-common/src/org/jetbrains/kotlin/incremental/storage/CachingLazyStorage.kt +++ b/build-common/src/org/jetbrains/kotlin/incremental/storage/CachingLazyStorage.kt @@ -103,7 +103,11 @@ class CachingLazyStorage( @Synchronized override fun close() { - storage?.close() + try { + storage?.close() + } finally { + storage = null + } } private fun createMap(): PersistentHashMap = PersistentHashMap(storageFile, keyDescriptor, valueExternalizer) diff --git a/build-common/src/org/jetbrains/kotlin/incremental/storage/NonCachingLazyStorage.kt b/build-common/src/org/jetbrains/kotlin/incremental/storage/NonCachingLazyStorage.kt index 755ea8262ec..d7bc82c1c1d 100644 --- a/build-common/src/org/jetbrains/kotlin/incremental/storage/NonCachingLazyStorage.kt +++ b/build-common/src/org/jetbrains/kotlin/incremental/storage/NonCachingLazyStorage.kt @@ -100,7 +100,11 @@ class NonCachingLazyStorage( @Synchronized override fun close() { - storage?.close() + try { + storage?.close() + } finally { + storage = null + } } private fun createMap(): PersistentHashMap =