nullpointerexceptioneclipse-rcpnattable

NullPointerException after adding Summary Row Layer in Nattable


We are Updating Nattable version to 2.0.2 from 1.6.0.

We are getting NPE in RowIdHideShowLayer when we are fetching the ILayerCell#getConfigLabels().

It happens only when we add summary Row Layer, otherwise it works fine.

java.lang.NullPointerException: null
    at java.util.TreeMap.getEntry(TreeMap.java:347) 
    at java.util.TreeMap.containsKey(TreeMap.java:232) 
    at org.eclipse.nebula.widgets.nattable.hideshow.RowIdHideShowLayer.isRowIndexHidden(RowIdHideShowLayer.java:191) ~
    at org.eclipse.nebula.widgets.nattable.hideshow.RowIdHideShowLayer.getConfigLabelsByPosition(RowIdHideShowLayer.java:171) ~
    at org.eclipse.nebula.widgets.nattable.layer.AbstractIndexLayerTransform.getConfigLabelsByPosition(AbstractIndexLayerTransform.java:345) 
    at org.eclipse.nebula.widgets.nattable.selection.SelectionLayer.getConfigLabelsByPosition(SelectionLayer.java:581) 
    at org.eclipse.nebula.widgets.nattable.layer.AbstractLayerTransform.getConfigLabelsByPosition(AbstractLayerTransform.java:341) 
    at org.eclipse.nebula.widgets.nattable.layer.CompositeLayer.getConfigLabelsByPosition(CompositeLayer.java:593) 
    at org.eclipse.nebula.widgets.nattable.layer.AbstractLayerTransform.getConfigLabelsByPosition(AbstractLayerTransform.java:341) 
    at org.eclipse.nebula.widgets.nattable.layer.CompositeLayer.getConfigLabelsByPosition(CompositeLayer.java:593) 
    at org.eclipse.nebula.widgets.nattable.layer.cell.AbstractLayerCell.getConfigLabels(AbstractLayerCell.java:55) 

How do we fix it ?

NPE in RowIdHideShowLayer


Solution

  • This looks like a bug in the RowIdHideShowLayer. You can fix this by locally overriding isRowIndexHidden(int) and adding a null check.

    The fix in NatTable is handled here: https://bugs.eclipse.org/bugs/show_bug.cgi?id=580072