RFR: 8347753: VetoableListDecorator doesn't accept its own sublists for bulk operations

Michael Strauß mstrauss at openjdk.org
Wed Jan 15 00:37:49 UTC 2025


Passing a `VetoableListDecorator.subList()` to any of its bulk operations (`addAll`, `setAll`, `removeAll`, `retainAll`) throws `ConcurrentModificationException`. The reason is that the `VetoableListDecorator.modCount` field is incremented before the underlying list's bulk operation is invoked, which causes a mismatch when the sublist is interrogated by the bulk operation.

However, simply updating the `modCount` field _after_ the underlying list was modified also doesn't work, as in this case listeners can't see the correct value for `modCount` in their callback. The fix is to make a defensive copy of the sublist before invoking the underlying list's bulk operation.

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

Commit messages:
 - allow sublists to be used for bulk operations
 - failing tests

Changes: https://git.openjdk.org/jfx/pull/1679/files
  Webrev: https://webrevs.openjdk.org/?repo=jfx&pr=1679&range=00
  Issue: https://bugs.openjdk.org/browse/JDK-8347753
  Stats: 140 lines in 2 files changed: 89 ins; 5 del; 46 mod
  Patch: https://git.openjdk.org/jfx/pull/1679.diff
  Fetch: git fetch https://git.openjdk.org/jfx.git pull/1679/head:pull/1679

PR: https://git.openjdk.org/jfx/pull/1679


More information about the openjfx-dev mailing list