commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From robert burrell donkin <>
Subject Re: [beanutils] PropertyUtils.setProperty on classes which extend Map
Date Tue, 26 Nov 2002 20:14:30 GMT

On Tuesday, November 26, 2002, at 07:26 PM, Craig R. McClanahan wrote:

> On Tue, 26 Nov 2002, robert burrell donkin wrote:
>> Date: Tue, 26 Nov 2002 19:12:21 +0000
>> From: robert burrell donkin <>
>> Reply-To: Jakarta Commons Developers List <commons-
>> To: Jakarta Commons Developers List <>
>> Subject: Re: [beanutils] PropertyUtils.setProperty on classes which
>>     extend Map
>> On Monday, November 25, 2002, at 11:25 PM, Craig R. McClanahan wrote:
>>> On Mon, 25 Nov 2002, robert burrell donkin wrote:
>> <snip>
>>> AFAIK, we've never promised that the BeanUtils or PropertyUtils code
>>> formally support Maps as the *destination* of a property set operation,
>>> even though they are acceptable as the source in certain scenarios.  In
>>> addition, if we're going to support setting via PropertyUtils, we
>>> certainly should support getting for symmetry.
>> i certainly agree with the point above but... just to be clear (which i
>> probably wasn't before)
>> the bug (as far as i understand it) concerns setting normal bean
>> properties on a bean that extends Hashtable. i have a bean with a 
>> property
>> that is set successfully when the class doesn't extend hashtable. when i
>> change the class definition so that it extends Hashtable, the property is
>> no longer set by PropertyUtils.
> Not remembering the details, is it possible that by extending Hashtable
> you're creating a situation where you have a property that violates the
> JavaBean spec's naming patterns (such as having two setters, or a setter
> and a getter with different property types)?  That would certainly cause 
> a
> problem like this.

i've taken a look at the code. there's no problem with setSimpleProperty 
but setProperty fails.

this calls setNestedProperty. this method checks to see if bean instanceof 
Map and if so, put's the value keyed by the property name into the map 
rather than looking for a property setter.

IMHO the bug poster's right that the correct behaviour should be that if 
there is a matching property then that should be called instead of putting 
the value in the map. unless anyone has any objections i'll create a fix 
along those lines...

- robert

To unsubscribe, e-mail:   <>
For additional commands, e-mail: <>

View raw message