commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bugzi...@apache.org
Subject DO NOT REPLY [Bug 14440] New: - PropertyUtils.setProperty Ignores Property Setter
Date Mon, 11 Nov 2002 10:57:12 GMT
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:   <mailto:commons-dev-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <mailto:commons-dev-help@jakarta.apache.org>


Mime
View raw message