On Fri, 24 Mar 2023 10:34:54 GMT, Prasanta Sadhukhan <[email protected]> 
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

This pull request has now been integrated.

Changeset: b659c353
Author:    Prasanta Sadhukhan <[email protected]>
URL:       
https://git.openjdk.org/jdk/commit/b659c35395fd3ac284a8fccfc04a4adf97438fb5
Stats:     171 lines in 3 files changed: 158 ins; 0 del; 13 mod

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

Reviewed-by: abhiscxk, aghaisas

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

PR: https://git.openjdk.org/jdk/pull/13172

Reply via email to