Return-Path: Delivered-To: apmail-cocoon-dev-archive@www.apache.org Received: (qmail 42779 invoked from network); 20 Jun 2006 15:12:56 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (209.237.227.199) by minotaur.apache.org with SMTP; 20 Jun 2006 15:12:56 -0000 Received: (qmail 14456 invoked by uid 500); 20 Jun 2006 15:12:54 -0000 Delivered-To: apmail-cocoon-dev-archive@cocoon.apache.org Received: (qmail 13970 invoked by uid 500); 20 Jun 2006 15:12:53 -0000 Mailing-List: contact dev-help@cocoon.apache.org; run by ezmlm Precedence: bulk list-help: list-unsubscribe: List-Post: Reply-To: dev@cocoon.apache.org List-Id: Delivered-To: mailing list dev@cocoon.apache.org Received: (qmail 13959 invoked by uid 99); 20 Jun 2006 15:12:53 -0000 Received: from asf.osuosl.org (HELO asf.osuosl.org) (140.211.166.49) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 20 Jun 2006 08:12:53 -0700 X-ASF-Spam-Status: No, hits=0.0 required=10.0 tests= X-Spam-Check-By: apache.org Received: from [209.237.227.198] (HELO brutus.apache.org) (209.237.227.198) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 20 Jun 2006 08:12:53 -0700 Received: from brutus (localhost [127.0.0.1]) by brutus.apache.org (Postfix) with ESMTP id 2C85D410005 for ; Tue, 20 Jun 2006 15:11:30 +0000 (GMT) Message-ID: <9425114.1150816290158.JavaMail.jira@brutus> Date: Tue, 20 Jun 2006 15:11:30 +0000 (GMT+00:00) From: "Antonio Gallardo (JIRA)" To: dev@cocoon.apache.org Subject: [jira] Commented: (COCOON-1867) BeanConvertor uses a WeakHashMap in the wrong way. In-Reply-To: <8232556.1150812449790.JavaMail.jira@brutus> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-Virus-Checked: Checked by ClamAV on apache.org X-Spam-Rating: minotaur.apache.org 1.6.2 0/1000/N [ http://issues.apache.org/jira/browse/COCOON-1867?page=comments#action_12416912 ] 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: http://issues.apache.org/jira/browse/COCOON-1867 > 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: http://issues.apache.org/jira/secure/Administrators.jspa - For more information on JIRA, see: http://www.atlassian.com/software/jira