diff --git a/native/native.tests/tests/org/jetbrains/kotlin/konan/test/blackbox/support/util/SafeEnvironment.kt b/native/native.tests/tests/org/jetbrains/kotlin/konan/test/blackbox/support/util/SafeEnvironment.kt index 1ef4fdf332f..651b9415e12 100644 --- a/native/native.tests/tests/org/jetbrains/kotlin/konan/test/blackbox/support/util/SafeEnvironment.kt +++ b/native/native.tests/tests/org/jetbrains/kotlin/konan/test/blackbox/support/util/SafeEnvironment.kt @@ -43,7 +43,12 @@ internal object SafeEnvVars : Iterable { internal class SafeProperties : Iterable { // Properties are mutable. So, need to capture the current values. private val properties: Map = TreeMap().apply { - System.getProperties().forEach { (name, value) -> + // Cloning properties to protect from ConcurrentModificationException + // if another threads modifies them while we iterate through: + val systemProperties = System.getProperties().clone() as Properties + // (clone() is synchronized). + + systemProperties.forEach { (name, value) -> this[name.toString()] = value.toString() } }