Emmanuel Bourg created BEANUTILS-519:
----------------------------------------
Summary: setProperty fails silently on null maps
Key: BEANUTILS-519
URL: https://issues.apache.org/jira/browse/BEANUTILS-519
Project: Commons BeanUtils
Issue Type: Bug
Components: Bean / Property Utils
Affects Versions: 1.9.3
Reporter: Emmanuel Bourg
Adding an element to a null map with BeanUtils.setProperty() neither result in
an automatically instantiated Map containing the specified element, nor to a
NullPointerException. The method simply fails and returns silently. If the map
isn't created on the fly an exception should be thrown at least.
Here is a test case illustrating the issue:
{code}
public class BeanUtilsTest extends TestCase {
private static class Bean {
public Map<String, String> elements;
}
public void testSetPropertyWithNullMap() throws Exception {
Bean b = new Bean();
assertNull(b.elements);
BeanUtils.setProperty(b, "elements(FOO)", "BAR");
assertNotNull("Map is still null after calling
BeanUtils.setProperty()", b.elements);
assertTrue("Element not found", b.elements.containsKey("FOO"));
}
}
{code}
--
This message was sent by Atlassian JIRA
(v7.6.3#76005)