<Swing Dev> RFR: 4819544: SwingSet2 JTable Demo throws NullPointerException

Pankaj Bansal pbansal at openjdk.java.net
Wed Aug 4 13:51:28 UTC 2021


On Tue, 3 Aug 2021 08:23:19 GMT, Prasanta Sadhukhan <psadhukhan at openjdk.org> wrote:

> In the JTable demo, if we double click on the first cell in the Favorite Number column, delete the value and click on some
> other cell, a java.lang.NullPointerException is getting thrown.
> The flaw is in the TableDemo's TableModel getColumnClass() method which queries the value of cell 0 in the target column, and returns its Class. This logic seems to be flawed - an NPE will be thrown when the value in cell 0 is null.
> Fix by checking for null.

Verified that the NPE is not happening after the fix.

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

Marked as reviewed by pbansal (Reviewer).

PR: https://git.openjdk.java.net/jdk/pull/4969


More information about the swing-dev mailing list