vaadin / vaadin/framework

TreeGrid unexpected NullPointerException on unknown rowkey

Open
#11,662 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Stale workaround
Dominant language
Java
Stars
1.8k
Forks
717
Avg merge
2d 6h
Merged PRs (30d)
3

Description

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.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start in server/src/main/java/com/vaadin/ui/TreeGrid.java at registerTreeGridRpc and trace the call to HierarchicalDataCommunicator.collapse(T item, Integer index). Reproduce the datasource_1 to datasource_2 exchange over a slow connection, then verify that an old rowkey cannot cause a NullPointerException during expand or collapse.

Written by the indexing model from the issue text.

Assessment

Tech stack
java
Domain
frontend
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.