Description
I am using a Grid<HashMap<String, Serializable>>. Each map contains an ID entry, and my custom DataProvider overrides getId() to return that stable ID.
When I call refreshItem(row), then mutate a value inside the same map instance, and call refreshItem(row) again within the same roundtrip, DataCommunicator can accumulate multiple pending updates for the same logical item.
The entries have the same DataProvider.getId() value, but they are not considered equal by the internal updatedData set in the DataCommunicator because hashCode() depends on the map contents. Since updatedData is a HashSet, mutating the map after it has been added changes its equality/hash behavior and allows the same logical item to appear more than once.
This can lead to inconsistent frontend updates: the client may receive multiple updates for the same item ID with different values, so an older state may override a newer one.
Question: Is this expected behavior, or should DataCommunicator deduplicate pending item updates based on DataProvider.getId() instead of relying on the item instance’s equals() / hashCode()?
Expected outcome
Multiple refreshItem() calls for the same logical item, as identified by DataProvider.getId(), should be coalesced within the same roundtrip.
Only the latest state for that item ID should be sent to the client.
Minimal reproducible example
Steps to reproduce
Environment
Vaadin version: 24.9.5
Browsers
No response
Description
I am using a Grid<HashMap<String, Serializable>>. Each map contains an ID entry, and my custom DataProvider overrides getId() to return that stable ID.
When I call refreshItem(row), then mutate a value inside the same map instance, and call refreshItem(row) again within the same roundtrip, DataCommunicator can accumulate multiple pending updates for the same logical item.
The entries have the same DataProvider.getId() value, but they are not considered equal by the internal updatedData set in the DataCommunicator because hashCode() depends on the map contents. Since updatedData is a HashSet, mutating the map after it has been added changes its equality/hash behavior and allows the same logical item to appear more than once.
This can lead to inconsistent frontend updates: the client may receive multiple updates for the same item ID with different values, so an older state may override a newer one.
Question: Is this expected behavior, or should DataCommunicator deduplicate pending item updates based on DataProvider.getId() instead of relying on the item instance’s equals() / hashCode()?
Expected outcome
Multiple refreshItem() calls for the same logical item, as identified by DataProvider.getId(), should be coalesced within the same roundtrip.
Only the latest state for that item ID should be sent to the client.
Minimal reproducible example
Steps to reproduce
Environment
Vaadin version: 24.9.5
Browsers
No response