SetPropertyRule throws /java.lang.IllegalArgumentException: No name specified/ 
when matched element has no attributes
---------------------------------------------------------------------------------------------------------------------

                 Key: DIGESTER-114
                 URL: https://issues.apache.org/jira/browse/DIGESTER-114
             Project: Commons Digester
          Issue Type: Bug
    Affects Versions: 1.8
            Reporter: Britt Levy


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));
        }               


-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to