Commons Configuration
  1. Commons Configuration
  2. CONFIGURATION-109

[configuration] XMLConfiguration partially supports List properties

    Details

    • Type: Bug Bug
    • Status: Resolved
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: Nightly Builds
    • Fix Version/s: None
    • Component/s: None
    • Labels:
      None
    • Environment:

      Operating System: other
      Platform: Other

      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>

        Activity

        Hide
        Ricardo Gladwell added a comment -

        Created an attachment (id=12394)
        Ignore last patch: use this one instead.

        Show
        Ricardo Gladwell added a comment - Created an attachment (id=12394) Ignore last patch: use this one instead.
        Hide
        David Eric Pugh added a comment -

        I believe that your other patch fixed this issue.. Marking as invalid.

        Show
        David Eric Pugh added a comment - I believe that your other patch fixed this issue.. Marking as invalid.
        Hide
        Emmanuel Bourg added a comment -

        If this bug is fixed I'm changing the resolution to fixed.

        Show
        Emmanuel Bourg added a comment - If this bug is fixed I'm changing the resolution to fixed.

          People

          • Assignee:
            Unassigned
            Reporter:
            Emmanuel Bourg
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development