Skip to content

refactor: extract @VaadinSessionScoped activation into managed bean#515

Merged
mcollovati merged 2 commits into
mainfrom
feat/pluggable-vaadinsessionscope-context-activation
Jun 8, 2026
Merged

refactor: extract @VaadinSessionScoped activation into managed bean#515
mcollovati merged 2 commits into
mainfrom
feat/pluggable-vaadinsessionscope-context-activation

Conversation

@mcollovati

Copy link
Copy Markdown
Contributor

Move the activation predicate and storage-access logic out of VaadinSessionScopedContext into a nested ContextualStorageManager managed bean. The context becomes a thin delegator. As a side effect, applications may replace the bean via CDI @Specializes to adjust behavior — though the manager is intentionally undocumented and overriding it is at the integrator's own risk.

Adds integration tests covering the strict default and the lenient @Specializes scenario from a background thread that does not hold the session lock.

References #506

@github-actions

github-actions Bot commented May 26, 2026

Copy link
Copy Markdown

Test Results

131 tests  +9   131 ✅ +9   3m 39s ⏱️ +9s
 35 suites +2     0 💤 ±0 
 35 files   +2     0 ❌ ±0 

Results for commit 634cdd4. ± Comparison against base commit 96421da.

♻️ This comment has been updated with latest results.

@mcollovati
mcollovati marked this pull request as ready for review May 27, 2026 06:05
@mshabarov
mshabarov requested a review from heruan June 1, 2026 11:52
@mshabarov

Copy link
Copy Markdown
Contributor

Let's also follow the internal discussion in Slack.

Move the activation predicate and storage-access logic out of
`VaadinSessionScopedContext` into a nested `ContextualStorageManager`
managed bean. The context becomes a thin delegator. As a side
effect, applications may replace the bean via CDI `@Specializes` to
adjust behavior — though the manager is intentionally undocumented
and overriding it is at the integrator's own risk.

Adds integration tests covering the strict default and the lenient
`@Specializes` scenario from a background thread that does not hold
the session lock.

References #506
@mcollovati
mcollovati force-pushed the feat/pluggable-vaadinsessionscope-context-activation branch from b55d903 to f3b3b0f Compare June 1, 2026 12:02
`SessionContextSpecializesView` joined the spawned background thread
with a 5 s timeout: in the lenient `@Specializes` deployment the
thread waits in `VaadinSession#accessSynchronously` for the session
lock held by the joining request thread, so an unbounded join would
deadlock. Every click stalled the full 5 s and the assertions raced
the still-running thread.

The click listener now only starts the thread, removing the lock
inversion entirely. The thread increments a completion counter in
its `finally` block, and the tests synchronize on it via a new
`waitForCount()` helper before asserting.
@mcollovati
mcollovati requested a review from heruan June 3, 2026 05:49
@mcollovati
mcollovati merged commit 1111175 into main Jun 8, 2026
10 checks passed
@mcollovati
mcollovati deleted the feat/pluggable-vaadinsessionscope-context-activation branch June 8, 2026 13:30
@github-project-automation github-project-automation Bot moved this from 🔎Iteration reviews to Done in Vaadin Flow | Hilla | Kits ongoing work Jun 8, 2026
@vaadin-bot

Copy link
Copy Markdown

Hi @mcollovati and @mcollovati, when i performed cherry-pick to this commit to 15.2, i have encountered the following issue. Can you take a look and pick it manually?
Error Message:
Error: Command failed: git cherry-pick 1111175
error: could not apply 1111175... refactor: extract @VaadinSessionScoped activation into managed bean (#515)
hint: After resolving the conflicts, mark them with
hint: "git add/rm ", then run
hint: "git cherry-pick --continue".
hint: You can instead skip this commit with "git cherry-pick --skip".
hint: To abort and get back to the state before "git cherry-pick",
hint: run "git cherry-pick --abort".

@nico-fri

nico-fri commented Jun 9, 2026

Copy link
Copy Markdown

Is there a plan for when the new Vaadin CDI 16.x version will be released, and will it be included in that release, since only 15.2 is listed?

mcollovati added a commit that referenced this pull request Jun 9, 2026
…#515) (#516)

Move the activation predicate and storage-access logic out of
`VaadinSessionScopedContext` into a nested `ContextualStorageManager`
managed bean. The context becomes a thin delegator. As a side
effect, applications may replace the bean via CDI `@Specializes` to
adjust behavior — though the manager is intentionally undocumented
and overriding it is at the integrator's own risk.

Adds integration tests covering the strict default and the lenient
`@Specializes` scenario from a background thread that does not hold
the session lock.

References #506
@ZheSun88

ZheSun88 commented Jun 9, 2026

Copy link
Copy Markdown
Contributor

Hi @nico-fri ,

Vaadin CDI 16.0.2 has been released with this fix, you can get it from maven central already.
CDI 15.2.3 should be in maven central quite soon.

Vaadin Platform with the cooresponding CDI addon version will be released in the next weeks.

🙇

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

Projects

Development

Successfully merging this pull request may close these issues.

6 participants