Throw BuildDataCorruptedException when lookup operation cannot be performed
That is expected to force a rebuild (but it does not seem to be the case in case of parallel build). #KT-22535 #KT-22995
This commit is contained in:
@@ -26,6 +26,7 @@ import org.jetbrains.kotlin.incremental.storage.*
|
||||
import org.jetbrains.kotlin.utils.Printer
|
||||
import org.jetbrains.kotlin.utils.keysToMap
|
||||
import java.io.File
|
||||
import java.io.IOException
|
||||
import java.util.*
|
||||
|
||||
|
||||
@@ -47,11 +48,16 @@ open class LookupStorage(targetDataDir: File) : BasicMapsOwner(targetDataDir) {
|
||||
private var deletedCount: Int = 0
|
||||
|
||||
init {
|
||||
if (countersFile.exists()) {
|
||||
val lines = countersFile.readLines()
|
||||
size = lines[0].toInt()
|
||||
deletedCount = lines[1].toInt()
|
||||
try {
|
||||
if (countersFile.exists()) {
|
||||
val lines = countersFile.readLines()
|
||||
size = lines[0].toInt()
|
||||
deletedCount = lines[1].toInt()
|
||||
}
|
||||
} catch (e: Exception) {
|
||||
throw IOException("Could not read $countersFile", e)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Synchronized
|
||||
|
||||
@@ -16,16 +16,22 @@
|
||||
|
||||
package org.jetbrains.kotlin.jps.incremental
|
||||
|
||||
import org.jetbrains.jps.builders.storage.BuildDataCorruptedException
|
||||
import org.jetbrains.jps.builders.storage.StorageProvider
|
||||
import org.jetbrains.jps.incremental.storage.BuildDataManager
|
||||
import org.jetbrains.jps.incremental.storage.StorageOwner
|
||||
import org.jetbrains.kotlin.incremental.LookupStorage
|
||||
import java.io.File
|
||||
import java.io.IOException
|
||||
|
||||
@Synchronized
|
||||
fun <T> BuildDataManager.withLookupStorage(fn: (LookupStorage) -> T): T {
|
||||
val lookupStorage = getStorage(KotlinDataContainerTarget, JpsLookupStorageProvider)
|
||||
return fn(lookupStorage)
|
||||
try {
|
||||
val lookupStorage = getStorage(KotlinDataContainerTarget, JpsLookupStorageProvider)
|
||||
return fn(lookupStorage)
|
||||
} catch (e: IOException) {
|
||||
throw BuildDataCorruptedException(e)
|
||||
}
|
||||
}
|
||||
|
||||
private object JpsLookupStorageProvider : StorageProvider<JpsLookupStorage>() {
|
||||
|
||||
Reference in New Issue
Block a user