Commons Configuration
  1. Commons Configuration
  2. CONFIGURATION-123

[configuration] ConfigurationConverter.getProperties() and interpolate behaviour inconsequent with getList()

    Details

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

      Operating System: other
      Platform: Other

      Description

      Hi,

      when converting a Configuration object into a Properties object no variable
      interpolation takes place. E.g. you have a PropertiesConfiguration with:
      foo=bar
      interpolated=$

      {foo}

      If you dump the Properties object or use .getProperty("interpolated") you will
      get "${foo}

      " instead of "bar".
      If you convert the Configuration one would expect the real/interpolated values
      for use with a legacy method (or just any JDK method that just takes Properties).

      But as the converter uses Configuration.getList(key) that doesn't interpolate
      (why does getList not interpolate?) this doesn't happen. Probably one could just
      use getStringArray() instead as this method does interpolate.
      Is there a reason for AbstractConfiguration.getStringArray() working differently
      compared to getList() with regard to variable interpolation? At least a Javadoc
      note would be good, or did one just forget to call "interpolate" in both?

      Moreover it would be logical if getProperties() & related methods would allow to
      specify a separator char as ", " is nice to print but is more difficult to parse
      than just ",". Actually the AbstractConfiguration.setDelimiter() functionality
      would make it reasonable to allow the user to modify the default also when
      converting vice versa.

        Activity

        Hide
        Emmanuel Bourg added a comment -

        This is now fixed in SVN, thank you for reporting the issue Michael. getList()
        now returns a list of interpolated values and
        ConfigurationConverter.getProperties() will use the delimiter of the
        configuration instead of a comma. I also removed the extra space behind the comma.

        Show
        Emmanuel Bourg added a comment - This is now fixed in SVN, thank you for reporting the issue Michael. getList() now returns a list of interpolated values and ConfigurationConverter.getProperties() will use the delimiter of the configuration instead of a comma. I also removed the extra space behind the comma.
        Hide
        Oliver Heger added a comment -

        The reason why getList() does not perform any interpolation is because the
        interpolate() method supports only String results ATM, while a list in theory
        could contain arbitrary objects.

        Issue 35116 deals with enhanced interpolation features that provide support for
        other data types, too. In this context, getList() of course must perform
        interpolation as well.

        Show
        Oliver Heger added a comment - The reason why getList() does not perform any interpolation is because the interpolate() method supports only String results ATM, while a list in theory could contain arbitrary objects. Issue 35116 deals with enhanced interpolation features that provide support for other data types, too. In this context, getList() of course must perform interpolation as well.
        Hide
        Emmanuel Bourg added a comment -

        You are right, getList() should interpolate the values like getStringArray().
        The only method that is not supposed to perform an interpolation is getProperty().

        Regarding the list delimiter, we should probably use the configuration delimiter
        if possible (for instances of AbstractConfiguration) and default to a comma
        otherwise. I don't mind removing the space after the delimiter.

        I noticed we don't escape the delimiter in the properties of the list, this
        should be fixed too.

        Show
        Emmanuel Bourg added a comment - You are right, getList() should interpolate the values like getStringArray(). The only method that is not supposed to perform an interpolation is getProperty(). Regarding the list delimiter, we should probably use the configuration delimiter if possible (for instances of AbstractConfiguration) and default to a comma otherwise. I don't mind removing the space after the delimiter. I noticed we don't escape the delimiter in the properties of the list, this should be fixed too.

          People

          • Assignee:
            Unassigned
            Reporter:
            Michael Echerer
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development