Details
-
Bug
-
Status: Closed
-
Major
-
Resolution: Fixed
-
1.8
-
None
Description
A /java.lang.IllegalArgumentException: No name specified/ is thrown from the SetPropertyRule.begin(Attributes attributes) method if the attributes list is empty (attributes.getLength() = 0). The method should check the length of the attributes list and simply return if there are no attributes.
Add the follwowing to org.apache.commons.digester.SetPropertyRuleTestCase to reproduce:
/**
- Simple test xml document used in the tests.
*/
protected final static String TEST_XML_3 =
"<?xml version='1.0'?><root>" +
"<set/>" +
"</root>";
/**
- Test SetPropertyRule when matched XML element has no attributes.
*/
public void testElementWithNoAttributes() throws Exception { // Set up the rules we need digester.addObjectCreate("root", "org.apache.commons.digester.SimpleTestBean"); digester.addSetProperty("root/set", "name", "value"); // Parse the input - should not throw an exception SimpleTestBean bean = (SimpleTestBean) digester.parse(xmlTestReader(TEST_XML_3)); }