RFR: 8068824: Exception thrown in JTableHeader after clicking on popupmenu opened with right-click on header [v3]

Abhishek Kumar abhiscxk at openjdk.org
Tue Apr 4 10:09:17 UTC 2023


On Tue, 4 Apr 2023 10:02:21 GMT, Prasanta Sadhukhan <psadhukhan at openjdk.org> wrote:

>> The issue is observed on mouse right click on the table header to open a pupup menu and then, do a mouse left click on the menu entry in which case we get AIOOBE
>> This is because the columnIndex for popup menu is returned by `viewIndexForColumn `as -1 seen here https://github.com/openjdk/jdk/blob/941a7ac7dab243c6033a78880fd31faa803e62ab/src/java.desktop/share/classes/javax/swing/plaf/basic/BasicTableHeaderUI.java#L745-L753
>> which is then passed to DefaultTableColumnModel.getColumn(columnIndex) causing it to throw AIOOBE as per the [DefaultTableColumnModel.getColumn spec](https://github.com/openjdk/jdk/blob/master/src/java.desktop/share/classes/javax/swing/table/DefaultTableColumnModel.java#L293)
>> 
>> So, inline with check done for `viewIndexForColumn `
>> https://github.com/openjdk/jdk/blob/941a7ac7dab243c6033a78880fd31faa803e62ab/src/java.desktop/share/classes/javax/swing/plaf/basic/BasicTableHeaderUI.java#L310-L312
>> a similar check is added when `viewIndexForColumn `is called
>
> Prasanta Sadhukhan has updated the pull request incrementally with one additional commit since the last revision:
> 
>   test fix

Test verified. Looks good to me.

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

Marked as reviewed by abhiscxk (Committer).

PR Review: https://git.openjdk.org/jdk/pull/13172#pullrequestreview-1370629853



More information about the client-libs-dev mailing list