Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 581505

Summary: NPE in SelectionLayerPainter#isInCurrentLayer()
Product: [Technology] NatTable Reporter: Dirk Fauth <dirk.fauth>
Component: CoreAssignee: Dirk Fauth <dirk.fauth>
Status: CLOSED FIXED QA Contact:
Severity: normal    
Priority: P3    
Version: 2.0.5   
Target Milestone: 2.1.0   
Hardware: PC   
OS: Windows 10   
See Also: https://git.eclipse.org/r/c/nattable/org.eclipse.nebula.widgets.nattable/+/199816
https://git.eclipse.org/c/nattable/org.eclipse.nebula.widgets.nattable.git/commit/?id=f0dedb4add30dcfd29931b876bd42ebe35f1de38
Whiteboard:

Description Dirk Fauth CLA 2023-02-08 12:28:47 EST
In the following scenario it can happen that a NPE is thrown in SelectionLayerPainter#isInCurrentLayer().

- open a filterable example (e.g. _6031_GlazedListsFilterExample)
- have a size that a horizontal scrollbar exists
- scroll down a bit
- apply a filter to reduce the list size so that the horizontal scrollbar disappears

In the back the following exception is thrown:

[main] ERROR org.eclipse.nebula.widgets.nattable.painter.layer.NatLayerPainter - Error while painting table
java.lang.NullPointerException
       at org.eclipse.nebula.widgets.nattable.selection.SelectionLayerPainter.isInCurrentLayer(SelectionLayerPainter.java:343)
       at org.eclipse.nebula.widgets.nattable.selection.SelectionLayerPainter.getBorderCells(SelectionLayerPainter.java:219)
       at org.eclipse.nebula.widgets.nattable.selection.SelectionLayerPainter.paintLayer(SelectionLayerPainter.java:125)
       at org.eclipse.nebula.widgets.nattable.layer.CompositeLayer$CompositeLayerPainter.paintLayer(CompositeLayer.java:1069)
       at org.eclipse.nebula.widgets.nattable.painter.layer.NatLayerPainter.paintLayer(NatLayerPainter.java:61)
       at org.eclipse.nebula.widgets.nattable.NatTable.paintNatTable(NatTable.java:519)
       at org.eclipse.nebula.widgets.nattable.NatTable.paintControl(NatTable.java:514)
       at org.eclipse.swt.widgets.TypedListener.handleEvent(TypedListener.java:234)
       at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:89)
       at org.eclipse.swt.widgets.Display.sendEvent(Display.java:4173)
       at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1057)
       at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1081)
       at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1066)
       at org.eclipse.swt.widgets.Composite.WM_PAINT(Composite.java:1563)
       at org.eclipse.swt.widgets.Control.windowProc(Control.java:4818)
       at org.eclipse.swt.widgets.Canvas.windowProc(Canvas.java:348)
       at org.eclipse.swt.widgets.Display.windowProc(Display.java:4812)
       at org.eclipse.swt.internal.win32.OS.DispatchMessage(Native Method)
       at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3583)
       at org.eclipse.nebula.widgets.nattable.examples.runner.StandaloneNatExampleRunner.run(StandaloneNatExampleRunner.java:45)
       at org.eclipse.nebula.widgets.nattable.examples.runner.StandaloneNatExampleRunner.run(StandaloneNatExampleRunner.java:25)
       at org.eclipse.nebula.widgets.nattable.examples._600_GlazedLists._603_Filter._6031_GlazedListsFilterExample.main(_6031_GlazedListsFilterExample.java:84)

This can happen if an area is painted that is bigger than the new NatTable. In this case the BorderCell array contains null values. 

To fix this null checks need to be added in the BorderCell bounds checks.
Comment 1 Eclipse Genie CLA 2023-02-08 12:32:10 EST
New Gerrit change created: https://git.eclipse.org/r/c/nattable/org.eclipse.nebula.widgets.nattable/+/199816
Comment 3 Dirk Fauth CLA 2023-03-31 03:47:12 EDT
Fixed with 2.1.0