Uploaded image for project: 'Commons Configuration'
  1. Commons Configuration
  2. CONFIGURATION-109

[configuration] XMLConfiguration partially supports List properties

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Resolved
    • Major
    • Resolution: Fixed
    • Nightly Builds
    • None
    • None
    • None
    • Operating System: other
      Platform: Other

    • 30071

    Description

      XMLConfiguration doesn't fully support list properties, while you can call
      addProperty with the same key several times to build a list of values, you can't
      call addProperty directly with a List value, it results in a ClassCastException
      when setXmlProperty tries to cast it into a String to create the text node.

      List list = new ArrayList();
      list.add("value1");
      list.add("value2");

      conf.addProperty("test.list", list);

      Also list properties are not saved properly, the values are concatenated like this:

      <configuration>
      <test>
      <list>value1value2</list>
      </test>
      </configuration>

      The list should appear like this instead:

      <configuration>
      <test>
      <list>value1</list>
      <list>value2</list>
      </test>
      </configuration>

      Last issue identified, if the list is stored in an attribute:

      conf.addProperty("test.attribute[@list]", "value1");
      conf.addProperty("test.attribute[@list]", "value2");

      only the last element is saved:

      <configuration>
      <test>
      <attribute list="value2"/>
      </test>
      </configuration>

      It is preferable to write the list as comma separated values:

      <configuration>
      <test>
      <attribute list="value1, value2"/>
      </test>
      </configuration>

      Attachments

        Activity

          People

            Unassigned Unassigned
            ebourg Emmanuel Bourg
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: