RFR: 8233179: VetoableListDecorator#sort throws IllegalArgumentException "duplicate children" [v3]

Michael Strauß mstrauss at openjdk.org
Tue Feb 25 19:05:23 UTC 2025


> 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.

Michael Strauß has updated the pull request with a new target base due to a merge or a rebase. The pull request now contains five commits:

 - merge
 - Merge branch 'master' into fixes/vetoable-list-decorator-sort
   
   # Conflicts:
   #	modules/javafx.base/src/main/java/com/sun/javafx/collections/VetoableListDecorator.java
 - factor out setAll implementation
 - Implement sorting for VetoableListDecorator
 - failing tests

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

Changes: https://git.openjdk.org/jfx/pull/1674/files
  Webrev: https://webrevs.openjdk.org/?repo=jfx&pr=1674&range=02
  Stats: 49 lines in 4 files changed: 40 ins; 4 del; 5 mod
  Patch: https://git.openjdk.org/jfx/pull/1674.diff
  Fetch: git fetch https://git.openjdk.org/jfx.git pull/1674/head:pull/1674

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


More information about the openjfx-dev mailing list