vaadin / framework

Vaadin 6, 7, 8 is a Java framework for modern Java web applications.
http://vaadin.com/
Other
1.78k stars 730 forks source link

TreeGrid unexpected NullPointerException on unknown rowkey #11662

Open GhostOlli opened 5 years ago

GhostOlli commented 5 years ago

Vaadin Version: 8.7.1 and above. Nothing to do with Browser version.

In following use-case I experience NullPointerExceptions in TreeGrid:

  1. Step TreeGrid using datasource_1
  2. Step on server side the datasource is exchanged with datasource_2 but on client side this change is not yet published fully due to slow connection
  3. User interacts with "old version" of TreeGrid (e.g. User tries to expand/collapses some items)
  4. User Got a NPE in HierarchicalDataCommunicator::collapse(T item, Integer index) because item given is null.

I think the issue is located in the following method:

https://github.com/vaadin/framework/blob/32aa5afc0217a767e85dd579525da5a2eb1163d9/server/src/main/java/com/vaadin/ui/TreeGrid.java#L177-L193

It seems there is a semantic conflict about the meaning of null as item in KeyMapper and the DataCommunicator. For the Keymapper null means invalid key/item and for the DataCommunicator null means root item in most cases.

So I think that's why the registerTreeGridRpc method fails: KeyMapper fails to map the given old rowkey so item is null. Method isCollapsed(item) thinks it's the root item which is always visible and collapse method cannot handle null as item item input.

TatuLund commented 5 years ago

I would assume that applicable workaround in this scenario is to create a new TreeGrid with datasource_2 and remove old TreeGrid from the view and replace it with new one.

stale[bot] commented 4 years ago

Hello there!

We are sorry that this issue hasn't progressed lately. We are prioritizing issues by severity and the number of customers we expect are experiencing this and haven't gotten around to fix this issue yet.

There are a couple of things you could help to get things rolling on this issue (this is an automated message, so expect that some of these are already in use):

Thanks again for your contributions! Even though we haven't been able to get this issue fixed, we hope you to report your findings and enhancement ideas in the future too!