RFR: 8138842: TableViewSelectionModel.selectIndices does not select index 0
John Hendrikx
jhendrikx at openjdk.org
Tue Jan 31 19:35:00 UTC 2023
On Tue, 31 Jan 2023 14:40:00 GMT, Karthik P K <kpk at openjdk.org> wrote:
> In `selectIndices` method, zero length array is not considered while ignoring row number given as parameter.
>
> Updated the code to consider both null and zero length array in the condition before ignoring the row value given as parameter.
>
> Added unit test to validate the fix
Change looks good, I just feel we shouldn't be catering to `null` here at all.
modules/javafx.controls/src/main/java/javafx/scene/control/TableView.java line 2645:
> 2643:
> 2644: @Override public void selectIndices(int row, int... rows) {
> 2645: if (rows == null || rows.length == 0) {
To get `rows` to be `null` you'd have to call this method as: `selectIndices(2, null)` -- IMHO that should result in an exception, and not be accepted to be the same as `selectIndices(2)` or `selectIndices(2, new int[0])`.
I checked the documentation, and it does not mention that `null` is allowed here, which means it isn't.
Also: weird method signature, but I guess if you want to enforce at least one parameter it could be done this way.
-------------
Marked as reviewed by jhendrikx (Committer).
PR: https://git.openjdk.org/jfx/pull/1018
More information about the openjfx-dev
mailing list