IndexOutOfRangeException in TreeTableRowSorter if node is updated but no sort performed yet.
Closed this issue · 2 comments
If a node with no children is expanded, and the table has not yet been sorted, then in TreeTableRowSorter.rowsUpdated(), it tries to check valid last known indices. However, if a sort has never been performed, then this fails with an IndexOutOfRangeException.
Interestingly, the TreeTableRowSorter implements the same behaviour in terms of throwing IndexOutOfBoundsExceptions as the DefaultRowSorter for a JTable. However, I guess there are some differences in terms of when this method is called during a row update.
Also need to check assumptions about index bounds when inserting and removing rows when sorting.
So, contract of RowSorter states that attempts to update, remove or insert on row indexes that are outside the model range or where the first index is greater than the last index should throw an IndexOutOfBoundsException.
I have added a test that only checks whether updates are within bounds if sorting is actually enabled.