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

Prasanta Sadhukhan psadhukhan at openjdk.java.net
Tue Aug 3 08:31:49 UTC 2021


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.

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

Commit messages:
 - 4819544: SwingSet2 JTable Demo throws NullPointerException
 - 4819544: SwingSet2 JTable Demo throws NullPointerException

Changes: https://git.openjdk.java.net/jdk/pull/4969/files
 Webrev: https://webrevs.openjdk.java.net/?repo=jdk&pr=4969&range=00
  Issue: https://bugs.openjdk.java.net/browse/JDK-4819544
  Stats: 7 lines in 1 file changed: 6 ins; 0 del; 1 mod
  Patch: https://git.openjdk.java.net/jdk/pull/4969.diff
  Fetch: git fetch https://git.openjdk.java.net/jdk pull/4969/head:pull/4969

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


More information about the swing-dev mailing list