Commons Configuration
  1. Commons Configuration
  2. CONFIGURATION-474

Lists don't seem to work whean loading INI files

    Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Minor Minor
    • Resolution: Fixed
    • Affects Version/s: 1.7
    • Fix Version/s: 1.8
    • Component/s: None
    • Labels:
      None

      Description

      After loading an INI file with HierarchicalINIConfiguration, getList() and getStringArray() alaways return 1-size sets even if the parameter is in the right form in the file. To reproduce one only need to create a small INI file with the following content :

      key=val1,val2,val3

      The following code returns a 1-sized list :

      HierarchicalINIConfiguration c = new HierarchicalINIConfiguration();
      c.load("test.ini");
      List<?> l = c.getList("val");
      

      => l = ["val1,val2,val3"] instead of ["val1","val2","val3"]

      I tried to change the list delimiter, but it didn't work. Maybe it's expected, but I haven't found anything in the doc.

        Activity

        Hide
        Oliver Heger added a comment -

        Indeed, in contrast to the deprecated INIConfiguration, HierarchicalINIConfiguration does not split comma-separated values. This should be added to be consistend with other configuration implementations. However, I would suggest to disable this feature by default to stay compatible with older versions. So in order to enable it, you would have to call setDelimiterParsingDisabled(false) before calling load().

        Thanks for the report.

        Show
        Oliver Heger added a comment - Indeed, in contrast to the deprecated INIConfiguration, HierarchicalINIConfiguration does not split comma-separated values. This should be added to be consistend with other configuration implementations. However, I would suggest to disable this feature by default to stay compatible with older versions. So in order to enable it, you would have to call setDelimiterParsingDisabled(false) before calling load() . Thanks for the report.
        Hide
        Charles Leclerc added a comment -

        I tried to add setDelimiterParsingDisabled(false) before calling load(), but it doesn't work either, the List is is still 1-sized.

        Show
        Charles Leclerc added a comment - I tried to add setDelimiterParsingDisabled(false) before calling load() , but it doesn't work either, the List is is still 1-sized.
        Hide
        Oliver Heger added a comment -

        Support for list delimiter parsing has been added in revision 1234362.

        However, it was not possible to switch off this behavior per default because HierarchicalINIConfiguration has constructors which directly call the load() method. At that moment the delimiterParsingDisabled flag is always false.

        So delimiter parsing now works and is enabled per default (which is alright because it is consistent with other Configuration implementations). I added a corresponding hint to the release notes as this may impact existing code.

        Show
        Oliver Heger added a comment - Support for list delimiter parsing has been added in revision 1234362. However, it was not possible to switch off this behavior per default because HierarchicalINIConfiguration has constructors which directly call the load() method. At that moment the delimiterParsingDisabled flag is always false . So delimiter parsing now works and is enabled per default (which is alright because it is consistent with other Configuration implementations). I added a corresponding hint to the release notes as this may impact existing code.

          People

          • Assignee:
            Oliver Heger
            Reporter:
            Charles Leclerc
          • Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development