Avoid instanciating LookupStorage when clearing it
#KT-22535
#KT-22995
Original commit: 7c9412a0b3
This commit is contained in:
@@ -380,7 +380,7 @@ class KotlinBuilder : ModuleLevelBuilder(BuilderCategory.SOURCE_PROCESSOR) {
|
||||
rebuildAfterCacheVersionChanged[target] = true
|
||||
}
|
||||
|
||||
dataManager.withLookupStorage { it.clean() }
|
||||
dataManager.cleanLookupStorage(LOG)
|
||||
return
|
||||
}
|
||||
CacheVersion.Action.REBUILD_CHUNK -> {
|
||||
@@ -405,7 +405,7 @@ class KotlinBuilder : ModuleLevelBuilder(BuilderCategory.SOURCE_PROCESSOR) {
|
||||
}
|
||||
CacheVersion.Action.CLEAN_DATA_CONTAINER -> {
|
||||
LOG.info("Clearing lookup cache")
|
||||
dataManager.withLookupStorage { it.clean() }
|
||||
dataManager.cleanLookupStorage(LOG)
|
||||
cacheVersionsProvider.dataContainerVersion().clean()
|
||||
}
|
||||
else -> {
|
||||
|
||||
@@ -16,6 +16,7 @@
|
||||
|
||||
package org.jetbrains.kotlin.jps.incremental
|
||||
|
||||
import com.intellij.openapi.diagnostic.Logger
|
||||
import org.jetbrains.jps.builders.storage.BuildDataCorruptedException
|
||||
import org.jetbrains.jps.builders.storage.StorageProvider
|
||||
import org.jetbrains.jps.incremental.storage.BuildDataManager
|
||||
@@ -24,13 +25,28 @@ import org.jetbrains.kotlin.incremental.LookupStorage
|
||||
import java.io.File
|
||||
import java.io.IOException
|
||||
|
||||
@Synchronized
|
||||
private object LookupStorageLock
|
||||
|
||||
fun BuildDataManager.cleanLookupStorage(log: Logger) {
|
||||
synchronized(LookupStorageLock) {
|
||||
try {
|
||||
cleanTargetStorages(KotlinDataContainerTarget)
|
||||
} catch (e: IOException) {
|
||||
if (!dataPaths.getTargetDataRoot(KotlinDataContainerTarget).deleteRecursively()) {
|
||||
log.debug("Could not clear lookup storage caches", e)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fun <T> BuildDataManager.withLookupStorage(fn: (LookupStorage) -> T): T {
|
||||
try {
|
||||
val lookupStorage = getStorage(KotlinDataContainerTarget, JpsLookupStorageProvider)
|
||||
return fn(lookupStorage)
|
||||
} catch (e: IOException) {
|
||||
throw BuildDataCorruptedException(e)
|
||||
synchronized(LookupStorageLock) {
|
||||
try {
|
||||
val lookupStorage = getStorage(KotlinDataContainerTarget, JpsLookupStorageProvider)
|
||||
return fn(lookupStorage)
|
||||
} catch (e: IOException) {
|
||||
throw BuildDataCorruptedException(e)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user