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

Kevin Rushforth kcr at openjdk.org
Tue Feb 25 16:11:04 UTC 2025


On Mon, 27 Jan 2025 18:34:30 GMT, Michael Strauß <mstrauss at openjdk.org> wrote:

>> 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.
>
> Michael Strauß has updated the pull request with a new target base due to a merge or a rebase. The incremental webrev excludes the unrelated changes brought in by the merge/rebase. The pull request contains six additional commits since the last revision:
> 
>  - update tests
>  - update tests
>  - check list content in tests
>  - Merge branch 'master' into fixes/vetoable-list-decorator-sublist
>  - allow sublists to be used for bulk operations
>  - failing tests

Code changes look good. I confirm that the new tests fail without the fix and pass with the fix.

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

Marked as reviewed by kcr (Lead).

PR Review: https://git.openjdk.org/jfx/pull/1679#pullrequestreview-2641657062


More information about the openjfx-dev mailing list