From 51a3fe367c01b2d564fce7bf786f72c2c0c07eb2 Mon Sep 17 00:00:00 2001 From: Kirill Rakhman Date: Mon, 18 Sep 2023 11:27:35 +0200 Subject: [PATCH] [Tests] Fix deadlock caused by eager initialization in JspecifyMarksCleanupPreprocessor --- .../preprocessors/JspecifyMarksCleanupPreprocessor.kt | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/compiler/tests-common-new/tests/org/jetbrains/kotlin/test/preprocessors/JspecifyMarksCleanupPreprocessor.kt b/compiler/tests-common-new/tests/org/jetbrains/kotlin/test/preprocessors/JspecifyMarksCleanupPreprocessor.kt index ff957facb97..b58ef8412cc 100644 --- a/compiler/tests-common-new/tests/org/jetbrains/kotlin/test/preprocessors/JspecifyMarksCleanupPreprocessor.kt +++ b/compiler/tests-common-new/tests/org/jetbrains/kotlin/test/preprocessors/JspecifyMarksCleanupPreprocessor.kt @@ -11,9 +11,9 @@ import org.jetbrains.kotlin.test.services.* class JspecifyMarksCleanupPreprocessor(testServices: TestServices) : SourceFilePreprocessor(testServices) { override fun process(file: TestFile, content: String) = content.replace(regexToCleanup, "") - - companion object { - private val jspecifyMarks = diagnosticsToJspecifyMarks.values.map { it.values }.flatten().joinToString("|") - private val regexToCleanup = Regex("""[ ]*// ($jspecifyMarks)(, ($jspecifyMarks))*(?:\r\n|\n)""") - } } + +// Properties need to be outside the preprocessor so that they aren't eagerly initialized, which leads to a deadlock +// when too many tests that have a dependency on this class are executed in parallel. +private val jspecifyMarks = diagnosticsToJspecifyMarks.values.map { it.values }.flatten().joinToString("|") +private val regexToCleanup = Regex("""[ ]*// ($jspecifyMarks)(, ($jspecifyMarks))*(?:\r\n|\n)""") \ No newline at end of file