On Mon, 31 Oct 2022 09:14:23 GMT, Prasanta Sadhukhan <[email protected]>
wrote:
>> If getDefaultEditor() is called before the JTable model is setup, it results
>> in NPE.
>>
>> This is because when JTable sets its model, which ends up firing a table
>> changed event. The testcase is listening for tableChanged events and
>> querying the editor. But the editor isn't installed until after the model is
>> set which results in NPE.
>> Fix is to ensure initializeLocalVars() which initializes default editor is
>> setup before JTable sets its model.
>>
>> No regression is observed in jtreg/jck testsuite with this change.
>
> Prasanta Sadhukhan has updated the pull request incrementally with one
> additional commit since the last revision:
>
> Remove extra line
Changes requested by aivanov (Reviewer).
test/jdk/javax/swing/JTable/JTableEditorNPE.java line 62:
> 60: });
> 61: } finally {
> 62: Thread.sleep(1000);
Is the `sleep` required?
If NPE is thrown, no UI appears at all; if NPE is not thrown, the UI may be
shown but not required.
Would it be enough to add the table to the frame and call `validate()`?
test/jdk/javax/swing/JTable/JTableEditorNPE.java line 118:
> 116: comp = renderer.getTableCellRendererComponent(
> 117: this, // table
> 118: getModel().getValueAt(row,column), // value
Suggestion:
getModel().getValueAt(row, column), // value
-------------
PR: https://git.openjdk.org/jdk/pull/10871