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

Bug 581254

Summary: Strange errors with DataChangeLayer if IRowIdAccessor is a lambda
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/+/197782
https://git.eclipse.org/c/nattable/org.eclipse.nebula.widgets.nattable.git/commit/?id=bc4dfb5891f1081e4617ce4a404019728b15eb60
Whiteboard:

Description Dirk Fauth CLA 2022-12-21 05:29:20 EST
Using the DataChangeLayer with the IdIndexKeyHandler, the changed data is identified by a row object via identifier that is retrieved via IRowIdAccessor. If the IRowIdAccessor is a lambda or a method reference, this is not working anymore and produces strange errors like NullPointerExceptions in various places.

The reason is that the type of the objects that are handled by the NatTable is retrieved via reflection by checking the method parameter type of the IRowIdAccessor. If this is a lambda or a method reference, the type is Object, which is not helpful.

To solve this there are three modifications:

1. if the type can not be resolved via IRowIdAccessor, check the type of the objects in the list
2. checking the objects in the list can fail if
  a) the list is initially empty
  b) the list contains subtypes, which would result in a sometimes working scenario
3. If the type can not be resolved (e.g. empty list and lambda) log an error
4. A reliable solution is to add a new constructor where the type can be passed to avoid the reflection
Comment 1 Eclipse Genie CLA 2022-12-21 05:31:30 EST
New Gerrit change created: https://git.eclipse.org/r/c/nattable/org.eclipse.nebula.widgets.nattable/+/197782
Comment 3 Dirk Fauth CLA 2023-03-31 03:50:27 EDT
Fixed with 2.1.0