[ 
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.

Reply via email to