Integrated: 8233179: VetoableListDecorator#sort throws IllegalArgumentException "duplicate children"

Michael Strauß mstrauss at openjdk.org
Thu Feb 27 23:36:05 UTC 2025


On Tue, 14 Jan 2025 00:55:36 GMT, Michael Strauß <mstrauss at openjdk.org> wrote:

> The `VetoableListDecorator` class does not override the default implementation of `List.sort()`. The default implementation copies the elements into an array, sorts the array, and then calls `List.set()` in a loop to sort the List **without removing the old elements first**. This leads to the `VetoableListDecorator` intercepting the call to `set()` and seeing a "duplicate child" being added.
> 
> The solution is to implement `SortableList.doSort()` with the following protocol:
> 1. Make a copy of the list and sort it.
> 2. Present the sorted list with `onProposedChange` for a potential veto.
> 3. If successful, use `setAll()` to swap out the current list with the sorted list.

This pull request has now been integrated.

Changeset: f3ba4485
Author:    Michael Strauß <mstrauss at openjdk.org>
URL:       https://git.openjdk.org/jfx/commit/f3ba44858efe16a4a82cdcd37c998023b3603eea
Stats:     49 lines in 4 files changed: 40 ins; 4 del; 5 mod

8233179: VetoableListDecorator#sort throws IllegalArgumentException "duplicate children"

Reviewed-by: kcr, angorya

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

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


More information about the openjfx-dev mailing list