Uploaded image for project: 'Commons Digester'
  1. Commons Digester
  2. DIGESTER-114

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

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 1.8
    • 1.8.1
    • 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)); }

      Attachments

        1. DIGESTER-114.patch
          2 kB
          Henri Yandell

        Activity

          People

            Unassigned Unassigned
            hblevy Britt Levy
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: