You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@commons.apache.org by "Davide Angelocola (JIRA)" <ji...@apache.org> on 2007/08/23 02:00:30 UTC

[jira] Created: (BEANUTILS-293) LazyDynaMap.getDynaProperties() bug

LazyDynaMap.getDynaProperties() bug
-----------------------------------

                 Key: BEANUTILS-293
                 URL: https://issues.apache.org/jira/browse/BEANUTILS-293
             Project: Commons BeanUtils
          Issue Type: Bug
          Components: Bean / Property Utils
    Affects Versions: 1.8.0-BETA
            Reporter: Davide Angelocola


        LazyDynaMap lazyDynaMap = new LazyDynaMap();
        lazyDynaMap.add("foo", String.class);
        assertNotNull(lazyDynaMap.getDynaProperties()[0].getType());

this test will fail. It is correct?

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


[jira] Resolved: (BEANUTILS-293) LazyDynaMap.getDynaProperties() bug

Posted by "Niall Pemberton (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/BEANUTILS-293?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Niall Pemberton resolved BEANUTILS-293.
---------------------------------------

    Resolution: Invalid

Probably is worth a javadoc comment - needs someone to jump in and do it though. Closing as INVALID.

> LazyDynaMap.getDynaProperties() bug
> -----------------------------------
>
>                 Key: BEANUTILS-293
>                 URL: https://issues.apache.org/jira/browse/BEANUTILS-293
>             Project: Commons BeanUtils
>          Issue Type: Bug
>          Components: Bean / Property Utils
>    Affects Versions: 1.8.0-BETA
>            Reporter: Davide Angelocola
>         Attachments: BEANUTILS-293-test.patch
>
>
>         LazyDynaMap lazyDynaMap = new LazyDynaMap();
>         lazyDynaMap.add("foo", String.class);
>         assertNotNull(lazyDynaMap.getDynaProperties()[0].getType());
> this test will fail. It is correct?

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


[jira] Commented: (BEANUTILS-293) LazyDynaMap.getDynaProperties() bug

Posted by "Henri Yandell (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/BEANUTILS-293?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_12525036 ] 

Henri Yandell commented on BEANUTILS-293:
-----------------------------------------

The problem is in LazyDynaBean's createOtherProperty method. It has:

        if (type == Object.class ||
            type == String.class ||
            type == Boolean.class ||
            type == Character.class ||
            Date.class.isAssignableFrom(type)) {
            return null;
        }

So any of those types will not get set up for some reason. I'm not sure why. Anyone know?

> LazyDynaMap.getDynaProperties() bug
> -----------------------------------
>
>                 Key: BEANUTILS-293
>                 URL: https://issues.apache.org/jira/browse/BEANUTILS-293
>             Project: Commons BeanUtils
>          Issue Type: Bug
>          Components: Bean / Property Utils
>    Affects Versions: 1.8.0-BETA
>            Reporter: Davide Angelocola
>         Attachments: BEANUTILS-293-test.patch
>
>
>         LazyDynaMap lazyDynaMap = new LazyDynaMap();
>         lazyDynaMap.add("foo", String.class);
>         assertNotNull(lazyDynaMap.getDynaProperties()[0].getType());
> this test will fail. It is correct?

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


[jira] Updated: (BEANUTILS-293) LazyDynaMap.getDynaProperties() bug

Posted by "Henri Yandell (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/BEANUTILS-293?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Henri Yandell updated BEANUTILS-293:
------------------------------------

    Attachment: BEANUTILS-293-test.patch

Doesn't seem like it should be correct. Attaching a patch with your example in the form of a unit test.

> LazyDynaMap.getDynaProperties() bug
> -----------------------------------
>
>                 Key: BEANUTILS-293
>                 URL: https://issues.apache.org/jira/browse/BEANUTILS-293
>             Project: Commons BeanUtils
>          Issue Type: Bug
>          Components: Bean / Property Utils
>    Affects Versions: 1.8.0-BETA
>            Reporter: Davide Angelocola
>         Attachments: BEANUTILS-293-test.patch
>
>
>         LazyDynaMap lazyDynaMap = new LazyDynaMap();
>         lazyDynaMap.add("foo", String.class);
>         assertNotNull(lazyDynaMap.getDynaProperties()[0].getType());
> this test will fail. It is correct?

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


[jira] Commented: (BEANUTILS-293) LazyDynaMap.getDynaProperties() bug

Posted by "Niall Pemberton (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/BEANUTILS-293?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_12525086 ] 

Niall Pemberton commented on BEANUTILS-293:
-------------------------------------------

LazyDynaMap is just a DynaBean wrapper for a Map - it just reflects the contents of the Map and doesn't actually store any "dyna" properties. So when you call the "add" method if it doesn't actually instantiate a default value then the "property" will not return a type. As Henri points out certain types (also Number instances) are not automatically instantiated by LazyDynaBean (which LazyDynaMap derives from) - however if you want different behaviour these classes are designed so that you can easily override in your own custom implementation. Perhaps LazyDynaMap is not suitable in this case - the main idea behind them was to provide lazy list/array growth for any Map - more with the idea that you can wrap an existing Map and have the lazy behaviour.

To answer Henri on "So any of those types will not get set up for some reason. I'm not sure why. Anyone know?" - the idea behind these "lazy" implementations was to provide two types of "lazy" behaviour - 1) lazy list/array growth and 2) automatic Map, list/array, Dyna Bean and POJO bean instantiation. The motivation behind both of these was to overcome the "nested null" type error when populating an object graph of more than one level. Unfortunately there is no way of identifiying someones custom POJO java bean - so it simply tries to exclude common non-bean type objects (Number instances are also not instantiated by default) - this isn't optimal, but the way its designed makes it easy for people to provide their own custom behaviour.

IMO this is working as designed and I'm going to close as not a problem. I would suggest resolving this in one of three ways:

1) Don't use LazyDynaMap (probably LazyDynaBean would be more suitable)
2) Override the LazyDynaMap default behaviour to provide default values
3) Don't use the "add" method - just set default values in the LazyDynaMap - e.g. lazyDynaMap.set("foo", ""); 


> LazyDynaMap.getDynaProperties() bug
> -----------------------------------
>
>                 Key: BEANUTILS-293
>                 URL: https://issues.apache.org/jira/browse/BEANUTILS-293
>             Project: Commons BeanUtils
>          Issue Type: Bug
>          Components: Bean / Property Utils
>    Affects Versions: 1.8.0-BETA
>            Reporter: Davide Angelocola
>         Attachments: BEANUTILS-293-test.patch
>
>
>         LazyDynaMap lazyDynaMap = new LazyDynaMap();
>         lazyDynaMap.add("foo", String.class);
>         assertNotNull(lazyDynaMap.getDynaProperties()[0].getType());
> this test will fail. It is correct?

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


[jira] Commented: (BEANUTILS-293) LazyDynaMap.getDynaProperties() bug

Posted by "Henri Yandell (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/BEANUTILS-293?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_12525381 ] 

Henri Yandell commented on BEANUTILS-293:
-----------------------------------------

Is it worth a javadoc comment on the add method?

> LazyDynaMap.getDynaProperties() bug
> -----------------------------------
>
>                 Key: BEANUTILS-293
>                 URL: https://issues.apache.org/jira/browse/BEANUTILS-293
>             Project: Commons BeanUtils
>          Issue Type: Bug
>          Components: Bean / Property Utils
>    Affects Versions: 1.8.0-BETA
>            Reporter: Davide Angelocola
>         Attachments: BEANUTILS-293-test.patch
>
>
>         LazyDynaMap lazyDynaMap = new LazyDynaMap();
>         lazyDynaMap.add("foo", String.class);
>         assertNotNull(lazyDynaMap.getDynaProperties()[0].getType());
> this test will fail. It is correct?

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