On Tue, 3 Aug 2021 08:23:19 GMT, Prasanta Sadhukhan <psadhuk...@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. Marked as reviewed by aivanov (Reviewer). src/demo/share/jfc/SwingSet2/TableDemo.java line 557: > 555: return obj.getClass(); > 556: } > 557: return Object.class; Shall the ternary conditional operator be used here? Suggestion: return obj != null ? obj.getClass() : Object.class; ------------- PR: https://git.openjdk.java.net/jdk/pull/4969