cocoon-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Antonio Gallardo (JIRA)" <j...@apache.org>
Subject [jira] Assigned: (COCOON-1867) BeanConvertor uses a WeakHashMap in the wrong way.
Date Sat, 07 Oct 2006 06:04:21 GMT
     [ http://issues.apache.org/jira/browse/COCOON-1867?page=all ]

Antonio Gallardo reassigned COCOON-1867:
----------------------------------------

    Assignee: Antonio Gallardo  (was: Simone Gianni)

> BeanConvertor uses a WeakHashMap in the wrong way.
> --------------------------------------------------
>
>                 Key: COCOON-1867
>                 URL: http://issues.apache.org/jira/browse/COCOON-1867
>             Project: Cocoon
>          Issue Type: Bug
>          Components: Blocks: Forms
>    Affects Versions: 2.1.9, 2.1.10-dev (current SVN)
>            Reporter: Simone Gianni
>         Assigned To: Antonio Gallardo
>            Priority: Critical
>         Attachments: BeanConvertor-1867.diff
>
>
> In the BeanConvertor, when a bean is converted to a string, the bean is stored in a WeakHashMap
this way :
> m_objects.put(idValue, value);
> Actually idValue is a string representing the bean (toString or evalued on id_path) while
the value is the bean.
> WeakHashMap DOES NOT remove a mapping when the bean is garbage collected, but actually
removes it when the KEY is garbage collected. This means that since the string is serialized
to XML in the form instance and then dropped, the mapping could be removed even while the
user is filling the form, with the conseguence that the convertor stops working, see a null
value, reports a validation error, even if the user correctly filled the form.
> This is even worse when you are using a selection list of beans, because in that case
the bean has no chanches to enter the m_objects map anymore, since the selection list has
been generated and stored st the beginning of the form (maybe thru flow, or on-create) and
is not asking the convertor to convert the beans anymore.
> A better solution (and IMMO what the author intended to do) is to remove the mapping
(so that the map does not hold references for everything) when the BEAN gets garbage collected.
In this case I'm experimenting with apache commons ReferenceMap, which actually can remove
mappings when the value (bean) is garbage collected.

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: http://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

Mime
View raw message