Skip to content

fix: check session lock in VaadinSessionScopedContext.isActive() - #499

Merged
mcollovati merged 2 commits into
mainfrom
issues/495-fix_vaadinsessionscope_active_check
Apr 22, 2026
Merged

fix: check session lock in VaadinSessionScopedContext.isActive()#499
mcollovati merged 2 commits into
mainfrom
issues/495-fix_vaadinsessionscope_active_check

Conversation

@mcollovati

Copy link
Copy Markdown
Contributor

Accessing @VaadinSessionScoped beans from background threads that have a VaadinSession set as current but don't hold the session lock causes an IllegalStateException from VaadinSession.getAttribute().

Check hasLock() in isActive() so the scope correctly reports as inactive without the lock, producing the expected
ContextNotActiveException instead.

Fixes #495

Accessing `@VaadinSessionScoped` beans from background threads that have
a `VaadinSession` set as current but don't hold the session lock causes
an `IllegalStateException` from `VaadinSession.getAttribute()`.

Check `hasLock()` in `isActive()` so the scope correctly reports as
inactive without the lock, producing the expected
`ContextNotActiveException` instead.

Fixes #495
@mcollovati
mcollovati marked this pull request as ready for review April 10, 2026 09:02
@mcollovati
mcollovati enabled auto-merge (squash) April 22, 2026 05:17
@github-actions

Copy link
Copy Markdown

Test Results

122 tests  +1   122 ✅ +1   2m 19s ⏱️ +4s
 33 suites ±0     0 💤 ±0 
 33 files   ±0     0 ❌ ±0 

Results for commit 5026ceb. ± Comparison against base commit 0f19e25.

@mcollovati
mcollovati merged commit 0d3aeeb into main Apr 22, 2026
9 of 10 checks passed
@mcollovati
mcollovati deleted the issues/495-fix_vaadinsessionscope_active_check branch April 22, 2026 05:23
mcollovati added a commit that referenced this pull request Apr 22, 2026
) (#505)

Accessing `@VaadinSessionScoped` beans from background threads that have
a `VaadinSession` set as current but don't hold the session lock causes
an `IllegalStateException` from `VaadinSession.getAttribute()`.

Check `hasLock()` in `isActive()` so the scope correctly reports as
inactive without the lock, producing the expected
`ContextNotActiveException` instead.

Fixes #495

Co-authored-by: Marco Collovati <marco@vaadin.com>
@vaadin-bot

Copy link
Copy Markdown

This ticket/PR has been released with Vaadin 25.1.4.

@vaadin-bot

Copy link
Copy Markdown

This ticket/PR has been released with Vaadin 25.2.0-alpha5.

@vaadin-bot

Copy link
Copy Markdown

This ticket/PR has been released with Vaadin 25.0.11.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Firing CDI-Event from a Subthread can cause IllegalStateException

3 participants