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 2002/11/11 11:57:12 UTC
DO NOT REPLY [Bug 14440] New: -
PropertyUtils.setProperty Ignores Property Setter
DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG
RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
<http://nagoya.apache.org/bugzilla/show_bug.cgi?id=14440>.
ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND
INSERTED IN THE BUG DATABASE.
http://nagoya.apache.org/bugzilla/show_bug.cgi?id=14440
PropertyUtils.setProperty Ignores Property Setter
Summary: PropertyUtils.setProperty Ignores Property Setter
Product: Commons
Version: 1.5 Final
Platform: Other
OS/Version: Windows XP
Status: NEW
Severity: Normal
Priority: Other
Component: Bean Utilities
AssignedTo: commons-dev@jakarta.apache.org
ReportedBy: rg@onepercentsoftware.com
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 {
Criteria c = new Criteria();
PropertyUtils.setSimpleProperty(c, "dbName", TEST_VAL);
assertEquals(TEST_VAL, c.getDbName());
}
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.
--
To unsubscribe, e-mail: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>