diff --git a/native/native.tests/tests/org/jetbrains/kotlin/konan/blackboxtest/TestCompiler.kt b/native/native.tests/tests/org/jetbrains/kotlin/konan/blackboxtest/TestCompiler.kt index 0f0de0ad211..e98c8e8b861 100644 --- a/native/native.tests/tests/org/jetbrains/kotlin/konan/blackboxtest/TestCompiler.kt +++ b/native/native.tests/tests/org/jetbrains/kotlin/konan/blackboxtest/TestCompiler.kt @@ -17,11 +17,10 @@ import org.jetbrains.kotlin.konan.blackboxtest.TestModule.Companion.allFriends import org.jetbrains.kotlin.konan.blackboxtest.util.* import org.jetbrains.kotlin.test.services.JUnit5Assertions.fail import java.io.* -import java.util.concurrent.ConcurrentHashMap import kotlin.system.measureTimeMillis internal class TestCompilationFactory(private val environment: TestEnvironment) { - private val cachedCompilations: MutableMap = ConcurrentHashMap() + private val cachedCompilations = ThreadSafeCache() private sealed interface TestCompilationCacheKey { data class Klib(val sourceModules: Set, val freeCompilerArgs: TestCompilerArgs) : TestCompilationCacheKey diff --git a/native/native.tests/tests/org/jetbrains/kotlin/konan/blackboxtest/TestRunProvider.kt b/native/native.tests/tests/org/jetbrains/kotlin/konan/blackboxtest/TestRunProvider.kt index 6dbab39e82c..149e43e9c55 100644 --- a/native/native.tests/tests/org/jetbrains/kotlin/konan/blackboxtest/TestRunProvider.kt +++ b/native/native.tests/tests/org/jetbrains/kotlin/konan/blackboxtest/TestRunProvider.kt @@ -8,19 +8,19 @@ package org.jetbrains.kotlin.konan.blackboxtest import com.intellij.openapi.util.Disposer import org.jetbrains.kotlin.konan.blackboxtest.TestCompilationResult.Companion.assertSuccess import org.jetbrains.kotlin.konan.blackboxtest.group.TestCaseGroupProvider +import org.jetbrains.kotlin.konan.blackboxtest.util.ThreadSafeCache import org.jetbrains.kotlin.test.services.JUnit5Assertions.assertTrue import org.jetbrains.kotlin.test.services.JUnit5Assertions.fail import org.junit.jupiter.api.Assumptions.assumeTrue import org.junit.jupiter.api.extension.ExtensionContext import java.io.File -import java.util.concurrent.ConcurrentHashMap internal class TestRunProvider( private val environment: TestEnvironment, private val testCaseGroupProvider: TestCaseGroupProvider ) : ExtensionContext.Store.CloseableResource { private val compilationFactory = TestCompilationFactory(environment) - private val cachedCompilations: MutableMap = ConcurrentHashMap() + private val cachedCompilations = ThreadSafeCache() fun getSingleTestRunForTestDataFile(testDataFile: File): TestRun { environment.assertNotDisposed() diff --git a/native/native.tests/tests/org/jetbrains/kotlin/konan/blackboxtest/util/ThreadSafe.kt b/native/native.tests/tests/org/jetbrains/kotlin/konan/blackboxtest/util/ThreadSafe.kt index 56c880d76cc..d05953329e5 100644 --- a/native/native.tests/tests/org/jetbrains/kotlin/konan/blackboxtest/util/ThreadSafe.kt +++ b/native/native.tests/tests/org/jetbrains/kotlin/konan/blackboxtest/util/ThreadSafe.kt @@ -26,7 +26,7 @@ internal class ThreadSafeFactory(private val function: (K) -> V) { internal class ThreadSafeCache { private val map = ConcurrentHashMap() - operator fun get(key: K): V = unwrap(map[key]) as V + operator fun get(key: K): V? = unwrap(map[key]) as V? fun computeIfAbsent(key: K, function: (K) -> V): V = unwrap(map.computeIfAbsent(key) { wrap(function(key)) }) as V }