RFR: 8189354: ArrayIndexOutOfBoundsException when listening to selection changes on TreeTableView [v2]

Jeanette Winzenburg fastegal at openjdk.java.net
Sun Apr 25 10:52:38 UTC 2021


On Sat, 24 Apr 2021 20:55:52 GMT, mstr2 <github.com+43553916+mstr2 at openjdk.org> wrote:

>> This PR fixes the implementation of `ControlUtils.reducingChange`, which incorrectly computed adjacent removed indices, thus resulting in incorrect removal notifications.
>> 
>> Since there were no unit tests for this method, I also added a bunch of tests.
>> 
>> After applying this fix, I can no longer reproduce [JDK-8189354](https://bugs.openjdk.java.net/browse/JDK-8189354) and [JDK-8189228](https://bugs.openjdk.java.net/browse/JDK-8189228).
>
> mstr2 has updated the pull request incrementally with two additional commits since the last revision:
> 
>  - Formatting
>  - Revert change to private ctor

Hmm .. don't quite understand why there _is_ this method: it is (only?) used in tree/TableView treeModificationListeners to sync (aka: remove and fire the appropriate changes) selected indices. In that particular case, removed is a sublist of selectedIndices (all selections in the subtree), that is they are already adjacent (in coordinates of selectedIndices). A single nextRemove should be okay, f.i. in TreeTableView

     int firstRemoved = selectedIndices.indexOf(removed.get(0));
     selectedIndices._nextRemove(firstRemoved, removed);
     // orig: not needed, all elements in removed _are_ adjacent (in coordinates of selectedIndices)
     //  ControlUtils.reducingChange(selectedIndices, removed);

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

PR: https://git.openjdk.java.net/jfx/pull/480


More information about the openjfx-dev mailing list