You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@commons.apache.org by bu...@apache.org on 2004/07/09 09:37:16 UTC

DO NOT REPLY [Bug 23815] - [beanutils]PropertyUtils.getNestedProperty() doesn't allow getXxxx on Map-Instances any longer

DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG 
RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
<http://issues.apache.org/bugzilla/show_bug.cgi?id=23815>.
ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND 
INSERTED IN THE BUG DATABASE.

http://issues.apache.org/bugzilla/show_bug.cgi?id=23815

[beanutils]PropertyUtils.getNestedProperty() doesn't allow getXxxx on Map-Instances any longer

niallp@apache.org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
            Summary|PropertyUtils.getNestedPrope|[beanutils]PropertyUtils.get
                   |rty() doesn't allow getXxxx |NestedProperty() doesn't
                   |on Map-Instances any longer |allow getXxxx on Map-
                   |                            |Instances any longer



------- Additional Comments From niallp@apache.org  2004-07-09 07:37 -------
Theres an inconsistency here. If you look at the setNestedProperty() method it 
has the following code:

if (bean instanceof Map) {

   // check to see if the class has a standard property 
   PropertyDescriptor descriptor = 
       getPropertyDescriptor(bean, name);
   if (descriptor == null) {
       // no - then put the value into the map
       ((Map) bean).put(name, value);
   } else {
       // yes - use that instead
       setSimpleProperty(bean, name, value);
   }

} else (....) {

So effectively it is doing what Jon suggested - check first if theres a 
property and if not and its a Map set the value. However the getNestedProperty
() doesn't do this so the two methods are inconsistent.

This inconsistency was pointed out by Senén in Bug 26904 and he/she requested 
that the get/setSimpleProperty handle Maps.

I agree that is what we do - in the get/setSimpleProperty methods first check 
if the property exists in the bean (if it does, use it) - if it doesn't then 
check if the bean is a Map (if it is then get/set the map's key value) 
otherwise throw the "unknown property" exception.

What do you think - does this satisfy Craig's issue with backwards 
compatibility? I'll attach a patch

Niall

---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org