You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@myfaces.apache.org by "Neil Griffin (JIRA)" <de...@myfaces.apache.org> on 2013/01/15 21:44:12 UTC

[jira] [Commented] (MYFACES-3675) Session scoped beans are not cleaned up when PortletSession expires or is invalidated

    [ https://issues.apache.org/jira/browse/MYFACES-3675?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13554303#comment-13554303 ] 

Neil Griffin commented on MYFACES-3675:
---------------------------------------

Here is a patched ManagedBeanDestroyer.isManagedBean(String) method:
{code}
    public boolean isManagedBean(String name)
    {
        boolean managed = false;
        
        if (_runtimeConfig.getManagedBean(name) == null)
        {
            
            // Section PLT.18.3 of the Portlet 2.0 Specification titled
            // "Binding Attributes into a Session" requires that
            // PortletSession attribute names be namespaced/prefixed with
            // the "javax.portlet.p.<ID>?" pattern. In order to determine
            // if the specified name is a SessionScoped managed-bean, it
            // is necessary to first strip the pattern from it.
            if ((name != null) && name.startsWith("javax.portlet.p."))
            {
                int pos = name.indexOf("?");
                if (pos > 0)
                {
                    String attributeName = name.substring(pos+1);
                    managed = (_runtimeConfig.getManagedBean(attributeName) != null);
                }
            }
        }
        else
        {
            managed = true;
        }
        return managed;
    }
{code}
                
> Session scoped beans are not cleaned up when PortletSession expires or is invalidated
> -------------------------------------------------------------------------------------
>
>                 Key: MYFACES-3675
>                 URL: https://issues.apache.org/jira/browse/MYFACES-3675
>             Project: MyFaces Core
>          Issue Type: Bug
>          Components: General
>    Affects Versions: 2.1.10
>         Environment: Portlets
>            Reporter: Neil Griffin
>
> When running in the context of a request, MyFaces calls FacesContext.getCurrentInstance().getExternalContext.getSessionMap() in order to get/set session attributes. This provides the portlet bridge with the ability to get/set attributes using the PortletSession, which is a layer of abstraction on top of the HttpSession. But when a session expires, the org.apache.myfaces.config.ManagedBeanDestroyer.isManagedBean(String) method does not check the attribute name for a portlet environment. This causes a memory leak when running in a portlet environment, because the portlet bridge is not consulted. Specifically, @SessionScoped managed-beans are not cleaned up.
> The good news is that Section PLT.18.3 of the Portlet 2.0 Specification titled "Binding Attributes into a Session" requires that PortletSession attribute names be namespaced/prefixed with the "javax.portlet.p.<ID>?" pattern when they are stored in the underlying HttpSession. This would enable MyFaces to find the session attributes, so that cleanup can take place correctly during session expiration/invalidation.
> Here is the parallel issue in Mojarra:
> http://java.net/jira/browse/JAVASERVERFACES-2691

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira