[ 
https://issues.apache.org/jira/browse/MYFACES-4782?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Thomas Andraschko resolved MYFACES-4782.
----------------------------------------
    Resolution: Fixed

> Limit the number of @ViewScoped bean storages per session (also with client 
> side state saving)
> ----------------------------------------------------------------------------------------------
>
>                 Key: MYFACES-4782
>                 URL: https://issues.apache.org/jira/browse/MYFACES-4782
>             Project: MyFaces Core
>          Issue Type: Improvement
>    Affects Versions: 4.0.0, 5.0.0, 4.1.0
>            Reporter: Thomas Andraschko
>            Assignee: Thomas Andraschko
>            Priority: Major
>             Fix For: 5.0.0, 4.0.5, 4.1.5
>
>
> With server side state saving, @ViewScoped beans are destroyed when their 
> view is removed from the session. This happens through 
> {{SerializedViewCollection}} and follows 
> {{org.apache.myfaces.NUMBER_OF_VIEWS_IN_SESSION}}.
> With client side state saving, no view state is kept in the session, so 
> nothing tracks the view scopes. Each request that creates a new view with a 
> @ViewScoped bean adds a new storage to {{ViewScopeContextualStorageHolder}}. 
> These storages are only destroyed when the view map is cleared, for example 
> on navigation, or when the session expires. If a page is requested again and 
> again, e.g. with plain GETs, the session grows without limit.
> Mojarra limits this with {{com.sun.faces.numberOfActiveViewMaps}} (default 
> 25) for both state saving methods.
> *Change:*
> * {{ViewScopeContextualStorageHolder}} keeps the view scope ids in LRU order. 
> When the number of active view scopes exceeds 
> {{org.apache.myfaces.NUMBER_OF_VIEWS_IN_SESSION}} (default 20), the least 
> recently used view scope and its beans are destroyed, including the 
> @PreDestroy callbacks.
> * The limit applies to client and server side state saving. With server side 
> state saving there are never more view scopes than stored views, so the 
> existing cleanup through {{SerializedViewCollection}} stays as it is, and the 
> new limit is only an extra safety net.
> * A postback to a view whose view scope was already evicted gets a new bean 
> instance. This is the same behavior as in Mojarra.
> Reported by Bauke Scholtz, see 
> https://balusc.omnifaces.org/2026/11/what-exactly-does-jakarta-faces-view.html



--
This message was sent by Atlassian Jira
(v10.3.26#10030026)

Reply via email to