Detect concurrent modifications in ArrayDeque #KT-63355

Remove the ArrayDeque.subList().subList() test for comodification detection.
For types that extend AbstractList and to not override subList function,
the behavior varies depending on JDK version. With JKD8, the test fails for ArrayDeque.
While with JDK9+, it passes.
This commit is contained in:
Abduqodiri Qurbonzoda
2024-01-12 18:46:10 +05:00
committed by Space Team
parent 5f16fb2e4d
commit c9d8ecc599
3 changed files with 113 additions and 9 deletions
@@ -234,6 +234,16 @@ public actual abstract class AbstractMutableList<E> protected actual constructor
return _size
}
override fun iterator(): MutableIterator<E> {
checkForComodification()
return super.iterator()
}
override fun listIterator(index: Int): MutableListIterator<E> {
checkForComodification()
return super.listIterator(index)
}
private fun checkForComodification() {
if (list.modCount != modCount)
throw ConcurrentModificationException()