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

Attribute value cannot delimit to list

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Open
    • Major
    • Resolution: Unresolved
    • 2.4
    • None
    • None
    • None
    • Important

    Description

      Given the following configuration XML:

      <configuration>
        <header>
          <result throwExceptionOnMissing="true">
            <listDelimiterHandler config-class="org.apache.commons.configuration2.convert.DefaultListDelimiterHandler">
              <config-constrarg config-value=","/>
            </listDelimiterHandler>
          </result>
        </header>
           <node type="test" types="a,b,c"/>
      </configuration>

      With the following test code:

                  Parameters params = new Parameters();
                  ReloadingFileBasedConfigurationBuilder<XMLConfiguration> builder = new ReloadingFileBasedConfigurationBuilder<XMLConfiguration>(XMLConfiguration.class);
                  builder.configure(params.xml().setFile(file).setListDelimiterHandler(new DefaultListDelimiterHandler(',')));
                  XMLConfiguration configuration = builder.getConfiguration();

              List<String> types = configuration.getList(String.class, "node[@types]");
              // result WRONG – returns ["a,b,c"]
              org.junit.Assert.assertEquals(types.size(), 3);

      I just couldn't find any way to get the attribute value as a comma-delimited list...

      In general, the default behavior change for list delimiter is a big headache while we are trying to upgrade to commons-configuration2...

      Attachments

        Activity

          People

            Unassigned Unassigned
            hchen00 Hao Chen
            Votes:
            1 Vote for this issue
            Watchers:
            4 Start watching this issue

            Dates

              Created:
              Updated: