RFR: 8340572: ConcurrentModificationException when sorting ArrayList sublists

Attila Szegedi attila at openjdk.org
Sun Sep 29 17:50:09 UTC 2024


Fixes a regression with #17818 where `ArrayList.subList(…).sort()` started incrementing `ArrayList.modCount` resulting in some cases throwing a `ConcurrentModificationException` where none was thrown before.

This change keeps the optimization from #17818 but restores the behavior where only sorting the `ArrayList` changes the mod count, but sorting its sublists does not.

-------------

Commit messages:
 - ConcurrentModificationException should not be thrown when sorting ArrayList subLists

Changes: https://git.openjdk.org/jdk/pull/21250/files
  Webrev: https://webrevs.openjdk.org/?repo=jdk&pr=21250&range=00
  Issue: https://bugs.openjdk.org/browse/JDK-8340572
  Stats: 44 lines in 2 files changed: 43 ins; 1 del; 0 mod
  Patch: https://git.openjdk.org/jdk/pull/21250.diff
  Fetch: git fetch https://git.openjdk.org/jdk.git pull/21250/head:pull/21250

PR: https://git.openjdk.org/jdk/pull/21250


More information about the core-libs-dev mailing list