Skip to content

fix: avoid NPE when canceling a JavaScript invocation of a closed UI (#25095) (CP: 25.2) - #25211

Merged
vaadin-bot merged 1 commit into
25.2from
cherry-pick-25095-to-25.2-1786621168549
Aug 13, 2026
Merged

fix: avoid NPE when canceling a JavaScript invocation of a closed UI (#25095) (CP: 25.2)#25211
vaadin-bot merged 1 commit into
25.2from
cherry-pick-25095-to-25.2-1786621168549

Conversation

@vaadin-bot

Copy link
Copy Markdown
Collaborator

This PR cherry-picks changes from the original PR #25095 to branch 25.2.

Original PR description

Invocations owned by an invisible component are retained in the UI's queue and get a detach listener registered for them. Registering that listener installs a handler on the invocation itself, and the handler stays attached to the invocation for the rest of its lifetime, since there is no way to unsubscribe it.

A component that keeps the PendingJavaScriptResult and cancels it after being reused in another UI therefore runs the handler installed by the closed UI, which dereferences its cleared session. Return early when the UI no longer has a session, as its invocation queue has already been released by then.

Also release the retained invocations when the UI is closed, so that the queue and the detach listener registrations on the state nodes do not outlive the UI when a detach listener fails and prevents the ones after it from running.

Fixes #25092

…25095)

Invocations owned by an invisible component are retained in the UI's
queue and get a detach listener registered for them. Registering that
listener installs a handler on the invocation itself, and the handler
stays attached to the invocation for the rest of its lifetime, since
there is no way to unsubscribe it.

A component that keeps the PendingJavaScriptResult and cancels it after
being reused in another UI therefore runs the handler installed by the
closed UI, which dereferences its cleared session. Return early when the
UI no longer has a session, as its invocation queue has already been
released by then.

Also release the retained invocations when the UI is closed, so that the
queue and the detach listener registrations on the state nodes do not
outlive the UI when a detach listener fails and prevents the ones after
it from running.

Fixes #25092
@vaadin-bot

Copy link
Copy Markdown
Collaborator Author

This PR is eligible for auto-merging policy, so it has been approved automatically. If there are pending conditions, auto merge (with 'squash' method) has been enabled for this PR [Message is sent from bot]

@vaadin-bot
vaadin-bot enabled auto-merge (squash) August 13, 2026 11:49
@github-actions

Copy link
Copy Markdown
Contributor

Test Results

 1 460 files  ±0   1 460 suites  ±0   1h 31m 19s ⏱️ + 7m 35s
10 331 tests +3  10 263 ✅ +3  68 💤 ±0  0 ❌ ±0 
10 803 runs  +3  10 734 ✅ +3  69 💤 ±0  0 ❌ ±0 

Results for commit 7570238. ± Comparison against base commit af5eca0.

@sonarqubecloud

Copy link
Copy Markdown

@vaadin-bot
vaadin-bot merged commit fa2d56a into 25.2 Aug 13, 2026
34 checks passed
@vaadin-bot
vaadin-bot deleted the cherry-pick-25095-to-25.2-1786621168549 branch August 13, 2026 11:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants