ENT-3187 Check that we're not calling toList on concurrent collections (#4828)

* ENT-3165 Kotlin toList() does not work on concurrent collections.  OS backport.

ENT-3165 Added comment.

* ENT-3187 Additional use of toList() on concurrent data structure.
This commit is contained in:
Rick Parker 2019-02-28 16:01:33 +00:00 committed by GitHub
parent cd321c9da2
commit adad7862d6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 4 additions and 2 deletions

View File

@ -62,7 +62,8 @@ class LazyPool<A>(
*/
fun close(): Iterable<A> {
lifeCycle.justTransition(State.FINISHED)
val elements = poolQueue.toList()
// Does not use kotlin toList() as it currently is not safe to use on concurrent data structures.
val elements = ArrayList(poolQueue)
poolQueue.clear()
return elements
}

View File

@ -163,7 +163,8 @@ class CordaPersistence(
}
fun onAllOpenTransactionsClosed(callback: () -> Unit) {
val allOpen = liveTransactions.values.toList()
// Does not use kotlin toList() as that is not safe to use on concurrent collections.
val allOpen = ArrayList(liveTransactions.values)
if (allOpen.isEmpty()) {
callback()
} else {