Skip to content

MYFACES-4751 5.0 Destroy @ViewScoped beans of views that are never sa…#997

Merged
melloware merged 1 commit into
apache:mainfrom
melloware:MYFACES-4751-50-ViewScoped
May 29, 2026
Merged

MYFACES-4751 5.0 Destroy @ViewScoped beans of views that are never sa…#997
melloware merged 1 commit into
apache:mainfrom
melloware:MYFACES-4751-50-ViewScoped

Conversation

@melloware
Copy link
Copy Markdown
Contributor

…ved (#995)

A view rendered without writing its state - e.g. a page with no UIForm, so no view state token is emitted - can never be restored, and unlike a saved view it is never registered in the session SerializedViewCollection. Consequently the normal "evict view -> destroy its view scope" path never ran for such a view, and any @ViewScoped beans created while rendering it lingered in the session (ViewScopeContextualStorageHolder) until the session expired. Requesting such a page repeatedly within one session therefore leaked one view-scope storage per request, unbounded.

FaceletViewDeclarationLanguage.renderView now destroys the view scope of a non-transient view whose state was not written, at the end of the request, publishing PreDestroyViewMapEvent and destroying its (CDI or non-CDI) @ViewScoped storage.

Add ViewScopeFormlessLeakTestCase: rendering a formless page bound to a @ViewScoped bean N times now destroys the bean N times instead of accumulating it in the session.

…ved (apache#995)

A view rendered without writing its state - e.g. a page with no UIForm, so no
view state token is emitted - can never be restored, and unlike a saved view it
is never registered in the session SerializedViewCollection. Consequently the
normal "evict view -> destroy its view scope" path never ran for such a view,
and any @ViewScoped beans created while rendering it lingered in the session
(ViewScopeContextualStorageHolder) until the session expired. Requesting such a
page repeatedly within one session therefore leaked one view-scope storage per
request, unbounded.

FaceletViewDeclarationLanguage.renderView now destroys the view scope of a
non-transient view whose state was not written, at the end of the request,
publishing PreDestroyViewMapEvent and destroying its (CDI or non-CDI)
@ViewScoped storage.

Add ViewScopeFormlessLeakTestCase: rendering a formless page bound to a
@ViewScoped bean N times now destroys the bean N times instead of accumulating
it in the session.

Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@melloware melloware force-pushed the MYFACES-4751-50-ViewScoped branch from 3b37239 to 13040eb Compare May 29, 2026 19:08
@melloware melloware merged commit b7300d6 into apache:main May 29, 2026
4 checks passed
@melloware melloware deleted the MYFACES-4751-50-ViewScoped branch May 29, 2026 19:32
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