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

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

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

Changes: https://git.openjdk.org/jdk/pull/13172/files
 Webrev: https://webrevs.openjdk.org/?repo=jdk&pr=13172&range=00
  Issue: https://bugs.openjdk.org/browse/JDK-8068824
  Stats: 154 lines in 3 files changed: 143 ins; 1 del; 10 mod
  Patch: https://git.openjdk.org/jdk/pull/13172.diff
  Fetch: git fetch https://git.openjdk.org/jdk.git pull/13172/head:pull/13172

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

Reply via email to