Integrated: 8347753: VetoableListDecorator doesn't accept its own sublists for bulk operations
Michael Strauß
mstrauss at openjdk.org
Tue Feb 25 17:58:09 UTC 2025
On Wed, 15 Jan 2025 00:32:37 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.
This pull request has now been integrated.
Changeset: 4f0f992a
Author: Michael Strauß <mstrauss at openjdk.org>
URL: https://git.openjdk.org/jfx/commit/4f0f992a9801e4fa20b2e6d7d693dd4bb8c34407
Stats: 147 lines in 2 files changed: 96 ins; 5 del; 46 mod
8347753: VetoableListDecorator doesn't accept its own sublists for bulk operations
Reviewed-by: angorya, kcr
-------------
PR: https://git.openjdk.org/jfx/pull/1679
More information about the openjfx-dev
mailing list