function MutableList<T>.moveDownAll() & moveUpAll() throw java.util.ConcurrentModificationException
shinobi9 opened this issue · comments
I notice there is a modify operation in for-Each. Is that a mistake?
version:
kotlin
tornadofx
javaFX
JVM
version:
kotlin: 1.5.21
tornadofx: 1.7.20
javaFX:
javafx.runtime.version=8.0.261
javafx.runtime.build=b12
JVM: 1.8 25.261-b12
snippet of the code in which the problem is reproduced
PS: I understand what the error is, but I want to make sure that it is not related to your code, but the problem is in tornadofx
mutableListOf(1, 2, 3, 4, 5, 6, 7, 8, 9, 10).apply { moveDownAll{ true } }.also { println(it) }
Is it my use wrong ?
The original code is missing. but just like this.
the problem is tornadofx. Although it is not clear why it began to reproduce right now. Try polle low version of Kotlin 1.4 or 1.3. Here is the code that fixes the problem.
inline fun <T> MutableList<T>.moveDownAll(crossinline predicate: (T) -> Boolean) = withIndex()
.filter { predicate(it.value) }
.forEach { moveDownAt(it.index) }
ok,thank you.
i will try later
It works well.
I think it is not worth closing, since the problem in the library has not been fixed