Details
-
Bug
-
Status: Closed
-
Major
-
Resolution: Fixed
-
1.5
-
None
-
None
-
None
-
Operating System: Windows XP
Platform: Other
-
14440
Description
When using PropertyUtils to set a property on an object that implements the
Map interface, undesirable behavior can result. In my case, I was trying to
use PropertyUtils (via BeanUtils) to set a property on an object of type
org.apache.util.Criteria, which implements Map. Using
PropertyUtils.setProperty ignores properties for which there is a legitimate
setter, instead placing the value in the map. It would be more intuitive if
the value were placed in the map only if no setter existed.
Here is sample code that illustrates this problem:
public class PropertyUtilsTest extends TestCase {
private static final String TEST_VAL = "_test-val_";
public void testPropUtils() {
try
catch (Throwable t)
{ t.printStackTrace(); } }
}
In this case, Criteria implements a setDbName() method that will not be called
by this code. This is somewhat confusing.