commons-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Niall Pemberton (JIRA)" <j...@apache.org>
Subject [jira] Resolved: (BEANUTILS-342) LazyDynaBean doesn't accept null value assignments for certain properties
Date Tue, 04 Aug 2009 22:40:14 GMT

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

Niall Pemberton resolved BEANUTILS-342.
---------------------------------------

    Resolution: Won't Fix

One of the "lazy" part of LazyDynaBean refers to lazy instantiation of properties

see http://commons.apache.org/beanutils/v1.8.0/apidocs/org/apache/commons/beanutils/package-summary.html#dynamic.lazy

This was intended behaviour, although sometimes its too aggressive. However LazyDynaBean's
behaviour was designed to be overriden with the set of  createXxxxxProperty() methods.

For example, if you override the createOtherProperty() method for your example then it should
resolve that issue:

http://commons.apache.org/beanutils/v1.8.0/apidocs/org/apache/commons/beanutils/LazyDynaBean.html#createOtherProperty(java.lang.String,
java.lang.Class)

{code}
public class MyLazyDynaBean extends LazyDynaBean {

    protected Object createOtherProperty(String name, Class type) {
        return null;
    }
}
{code}


> LazyDynaBean doesn't accept null value assignments for certain properties
> -------------------------------------------------------------------------
>
>                 Key: BEANUTILS-342
>                 URL: https://issues.apache.org/jira/browse/BEANUTILS-342
>             Project: Commons BeanUtils
>          Issue Type: Bug
>    Affects Versions: 1.8.0
>         Environment: Ubuntu Linux (Gutsy), Sun Java 1.6
>            Reporter: Andras Soltesz
>
> With certain object types, LazyDynaBean doesn't accept null assignments correctly. Even
if I set the null value (which is accepted without an error), when I query the property, I
get a non-null value.
> It works correctly if I do the following:
> - assign a null value to the property 
> - assign a real object value (non-null)
> - assign a null value again (this time it is accepted correctly)
> A small test script which demonstrates the issue:
> ---------------------------
>       LazyDynaBean bean = new LazyDynaBean();
>       Object value;
>       System.out.println("----------------------------");
>       bean.set("prop3", new Agent());
>       value = bean.get("prop3");
>       System.out.println("Prop3 value (should be an Agent): " + value);
>       bean.set("prop3", null);
>       value = bean.get("prop3");
>       System.out.println("Prop3 value (should be null): " + value);
>       System.out.println("----------------------------");
>       bean.set("prop4", null);
>       value = bean.get("prop4");
>       System.out.println("Prop4 value (should be null): " + value);
>       bean.set("prop4", new Agent());
>       value = bean.get("prop4");
>       System.out.println("Prop4 value (should be an Agent): " + value);
>       bean.set("prop4", null);
>       value = bean.get("prop4");
>       System.out.println("Prop4 value (should be null): " + value);
> --------------------
> I can't imagine that this is desired behaviour.
> As a temporary workaround, I have created a sublclass of LazyDynaBean with set() overridden,
so it always sets a null before it sets a real value.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


Mime
View raw message