Skip to content

#6152 Destroy client window scoped beans - #6154

Merged
BalusC merged 1 commit into
4.0from
issue_6152
Nov 9, 2026
Merged

BalusC merged 1 commit into
4.0from
issue_6152

Conversation

@BalusC

@BalusC BalusC commented Nov 9, 2026

Copy link
Copy Markdown
Contributor

Closes #6152

@ClientWindowScoped beans were never destroyed, on session destroy and on client window eviction. So @PreDestroy never ran and @Dependent objects were never released.

  • ClientWindowScopeContextObject stores the original CreationalContext. CDI requires the same instance for Contextual.destroy(), and only that instance holds the dependent objects.
  • sessionDestroyed() destroys the beans of all remaining client windows.
  • getContextMap() evicts the least recently used client window explicitly, and destroys its beans outside the lock. A callback in the LRUMap cannot hold a BeanManager, because the map is serialized with the session.
  • A bean which cannot be destroyed is logged and skipped, so that it cannot fail the request of another client window.

New IT test/issue6152 covers eviction, session destroy and dependent objects. It passes on GlassFish, WildFly and TomEE, and it fails on GlassFish without the fix.

Not tested on a real cluster. A serialization round trip of the bean with its CreationalContext works on Weld 5.1.6, and the CreationalContext implementations of Weld and OpenWebBeans are Serializable.

🤖 Generated with Claude Opus 5.5

@ClientWindowScoped beans were dropped without Contextual.destroy() on
session destroy and on client window eviction. So @PreDestroy never
ran and @dependent objects were never released.

Store the original CreationalContext, as only that one holds the
dependent objects. Destroy the beans of all remaining windows on
session destroy. Evict the eldest window explicitly, so that its beans
can be destroyed outside the lock.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@BalusC BalusC added this to the 4.0.30 milestone Nov 9, 2026
@BalusC
BalusC merged commit e5b8f92 into 4.0 Nov 9, 2026
2 checks passed
@BalusC
BalusC deleted the issue_6152 branch November 10, 2026 14:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant