I am wondering why do I get NPE in the following code:
@Override
public void updateItem(String item, boolean empty) {
if(empty){
super.updateItem(item, empty);
return;
}
MyTableRow currentRow = (MyTableRow) getTableRow().getItem();
currentRow.stringProperty(); // here I get NPE
}
The code snippet is from a custom TableCell, where the updateItem
is overridden.
At the commented line I get NPE, while the item
is not null, and also empty is false
. For me that means there is a row, so the getTableRow().getItem()
should not be null. That is true and is a solution(or an unnecessary workaround?) to make a nullcheck after I get the item's reference, but I think that is unnecessary. Did I missed or this is an expected outcome?