Skip to content

Grid with Map items does not coalesce multiple refreshItem() calls by DataProvider.getId() #24244

@evgeni-uv

Description

@evgeni-uv

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    Status

    📥Inbox - needs triage

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions