From dfead910b92e84a6156ef9397e3bd1510d41a5b3 Mon Sep 17 00:00:00 2001 From: Mikhail Mazurkevich Date: Wed, 7 Dec 2022 14:58:15 +0400 Subject: [PATCH] [jps] KT-55309 Remove obsolete `NonCachingLazyStorage` --- .../kotlin/incremental/storage/BasicMap.kt | 7 +- .../storage/NonCachingLazyStorage.kt | 116 ------------------ 2 files changed, 1 insertion(+), 122 deletions(-) delete mode 100644 build-common/src/org/jetbrains/kotlin/incremental/storage/NonCachingLazyStorage.kt 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 cbeb4869627..23e7d7dafd8 100644 --- a/build-common/src/org/jetbrains/kotlin/incremental/storage/BasicMap.kt +++ b/build-common/src/org/jetbrains/kotlin/incremental/storage/BasicMap.kt @@ -29,14 +29,9 @@ abstract class BasicMap, V>( valueExternalizer: DataExternalizer ) { protected val storage: LazyStorage - private val nonCachingStorage = System.getProperty("kotlin.jps.non.caching.storage")?.toBoolean() ?: false init { - storage = if (nonCachingStorage) { - NonCachingLazyStorage(storageFile, keyDescriptor, valueExternalizer) - } else { - CachingLazyStorage(storageFile, keyDescriptor, valueExternalizer) - } + storage = CachingLazyStorage(storageFile, keyDescriptor, valueExternalizer) } fun clean() { diff --git a/build-common/src/org/jetbrains/kotlin/incremental/storage/NonCachingLazyStorage.kt b/build-common/src/org/jetbrains/kotlin/incremental/storage/NonCachingLazyStorage.kt deleted file mode 100644 index 2bf17bcb8ed..00000000000 --- a/build-common/src/org/jetbrains/kotlin/incremental/storage/NonCachingLazyStorage.kt +++ /dev/null @@ -1,116 +0,0 @@ -/* - * Copyright 2010-2015 JetBrains s.r.o. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.jetbrains.kotlin.incremental.storage - -import com.intellij.util.io.DataExternalizer -import com.intellij.util.io.IOUtil -import com.intellij.util.io.KeyDescriptor -import com.intellij.util.io.PersistentHashMap -import java.io.File -import java.io.IOException - - -class NonCachingLazyStorage( - private val storageFile: File, - private val keyDescriptor: KeyDescriptor, - private val valueExternalizer: DataExternalizer -) : LazyStorage { - private var storage: PersistentHashMap? = null - - private fun getStorageIfExists(): PersistentHashMap? { - if (storage != null) return storage - - if (storageFile.exists()) { - storage = createMap() - return storage - } - - return null - } - - private fun getStorageOrCreateNew(): PersistentHashMap { - if (storage == null) { - storage = createMap() - } - - return storage!! - } - - override val keys: Collection - @Synchronized - get() = getStorageIfExists()?.allKeysWithExistingMapping ?: listOf() - - @Synchronized - override operator fun contains(key: K): Boolean = - getStorageIfExists()?.containsMapping(key) ?: false - - @Synchronized - override operator fun get(key: K): V? = - getStorageIfExists()?.get(key) - - @Synchronized - override operator fun set(key: K, value: V) { - getStorageOrCreateNew().put(key, value) - } - - @Synchronized - override fun remove(key: K) { - getStorageIfExists()?.remove(key) - } - - @Synchronized - override fun append(key: K, value: V) { - getStorageOrCreateNew().appendData(key) { dataOutput -> valueExternalizer.save(dataOutput, value) } - } - - @Synchronized - override fun clean() { - try { - storage?.close() - } finally { - storage = null - if (!IOUtil.deleteAllFilesStartingWith(storageFile)) { - throw IOException("Could not delete internal storage: ${storageFile.absolutePath}") - } - } - } - - @Synchronized - override fun flush(memoryCachesOnly: Boolean) { - val existingStorage = storage ?: return - - if (memoryCachesOnly) { - if (existingStorage.isDirty) { - existingStorage.dropMemoryCaches() - } - } else { - existingStorage.force() - } - } - - @Synchronized - override fun close() { - try { - storage?.close() - } finally { - storage = null - } - } - - private fun createMap(): PersistentHashMap = - PersistentHashMap(storageFile, keyDescriptor, valueExternalizer) -}