[Gradle] Clone Properties before iterating over them as it can cause...
...ConcurrentModificationException if someone will concurrently modify them
This commit is contained in:
committed by
Space Team
parent
f5d4984274
commit
ba20972449
+3
-6
@@ -137,8 +137,8 @@ abstract class KotlinToolRunner(
|
||||
val transformedArgs = transformArgs(args)
|
||||
val classpath = executionContext.filesProvider(classpath)
|
||||
val systemProperties = System.getProperties()
|
||||
/* Capture 'System.getProperties()' as List to avoid potential 'ConcurrentModificationException' */
|
||||
.toListSynchronized()
|
||||
/* Capture 'System.getProperties()' current state to avoid potential 'ConcurrentModificationException' */
|
||||
.snapshot()
|
||||
.asSequence()
|
||||
.map { (k, v) -> k.toString() to v.toString() }
|
||||
.filter { (k, _) -> k !in execSystemPropertiesBlacklist }
|
||||
@@ -226,9 +226,6 @@ abstract class KotlinToolRunner(
|
||||
else -> this
|
||||
}
|
||||
|
||||
/**
|
||||
* Safely enter the [Properties] monitor and capture the current values
|
||||
*/
|
||||
private fun Properties.toListSynchronized(): List<Pair<Any, Any>> = synchronized(this) { toList() }
|
||||
private fun Properties.snapshot(): Properties = clone() as Properties
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user