cocoon-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Antonio Gallardo (JIRA)" <>
Subject [jira] Commented: (COCOON-1867) BeanConvertor uses a WeakHashMap in the wrong way.
Date Tue, 20 Jun 2006 15:11:30 GMT
    [ ] 

Antonio Gallardo commented on COCOON-1867:

+1a Reference map is better for this task. Feel free to do the change.

> BeanConvertor uses a WeakHashMap in the wrong way.
> --------------------------------------------------
>          Key: COCOON-1867
>          URL:
>      Project: Cocoon
>         Type: Bug

>   Components: Blocks: Forms
>     Versions: 2.1.9, 2.1.10-dev (current SVN)
>     Reporter: Simone Gianni
>     Assignee: Simone Gianni
>     Priority: Critical

> 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:
For more information on JIRA, see:

View raw message