You are viewing a plain text version of this content. The canonical link for it is here.
Posted to pluto-dev@portals.apache.org by "Neil Griffin (JIRA)" <ji...@apache.org> on 2019/04/04 17:27:00 UTC

[jira] [Updated] (PLUTO-770) PortletSessionScopedBeanMap.remove() does not remove bean instances from the underlying map

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

Neil Griffin updated PLUTO-770:
-------------------------------
    Description: 
The {{PortletSessionScopedBeanMap.remove()}} method contains the following code:

{code:java|title=PortletSessionScopedBeanMap.java}
if (bi != null) {
    beans.remove(bean);
    bi.crco.release();
    bean.destroy((T)bi.instance, (CreationalContext<T>)bi.crco);
}
{code}

The problem is that the {{beans}} variable is a {{java.util.Map}} whose keys are of type {{String}} (the windowId of the portlet) and not of type {{javax.enterprise.inject.spi.Bean}}. Therefore the call to {{beans.remove(bean)}} is incorrect and does not actually remove the bean from the underlying map.

The fix would be to pass the windowId instead:

{code:java|title=PortletSessionScopedBeanMap.java}
if (bi != null) {
    beans.remove(id);
    bi.crco.release();
    bean.destroy((T)bi.instance, (CreationalContext<T>)bi.crco);
}
{code}

The reason why this was not discovered earlier is because the {{PortletSessionScopedBeanMap.remove()}} method was only called by the {{valueUnbound(HttpSessionBindingEvent evt)}} method which includes a call to {{beans.clear()}} after iterating through all the beans.


  was:
The {{PortletSessionScopedBeanMap.remove()}} method contains the following code:

{code:java|title=PortletSessionScopedBeanMap.java}
if (bi != null) {
    beans.remove(bean);
    bi.crco.release();
    bean.destroy((T)bi.instance, (CreationalContext<T>)bi.crco);
}
{code}

The problem is that the {{beans}} variable is a {{java.util.Map}} whose keys are of type {{String}} (the windowId of the portlet) and not of type {{javax.enterprise.inject.spi.Bean}}. Therefore the call to {{beans.remove(bean)}} is incorrect and does not actually remove the bean from the underlying map.

The fix would be to pass the windowId instead:

{code:java|title=PortletSessionScopedBeanMap.java}
if (bi != null) {
    beans.remove(id);
    bi.crco.release();
    bean.destroy((T)bi.instance, (CreationalContext<T>)bi.crco);
}
{code}



> PortletSessionScopedBeanMap.remove() does not remove bean instances from the underlying map
> -------------------------------------------------------------------------------------------
>
>                 Key: PLUTO-770
>                 URL: https://issues.apache.org/jira/browse/PLUTO-770
>             Project: Pluto
>          Issue Type: Task
>          Components: portlet container
>    Affects Versions: 3.0.0, 3.0.1
>            Reporter: Neil Griffin
>            Assignee: Neil Griffin
>            Priority: Major
>             Fix For: 3.0.2
>
>
> The {{PortletSessionScopedBeanMap.remove()}} method contains the following code:
> {code:java|title=PortletSessionScopedBeanMap.java}
> if (bi != null) {
>     beans.remove(bean);
>     bi.crco.release();
>     bean.destroy((T)bi.instance, (CreationalContext<T>)bi.crco);
> }
> {code}
> The problem is that the {{beans}} variable is a {{java.util.Map}} whose keys are of type {{String}} (the windowId of the portlet) and not of type {{javax.enterprise.inject.spi.Bean}}. Therefore the call to {{beans.remove(bean)}} is incorrect and does not actually remove the bean from the underlying map.
> The fix would be to pass the windowId instead:
> {code:java|title=PortletSessionScopedBeanMap.java}
> if (bi != null) {
>     beans.remove(id);
>     bi.crco.release();
>     bean.destroy((T)bi.instance, (CreationalContext<T>)bi.crco);
> }
> {code}
> The reason why this was not discovered earlier is because the {{PortletSessionScopedBeanMap.remove()}} method was only called by the {{valueUnbound(HttpSessionBindingEvent evt)}} method which includes a call to {{beans.clear()}} after iterating through all the beans.



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)