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

ConfirgurationPropertySource doesn't supply resolved values.

    XMLWordPrintableJSON

Details

    Description

      Per https://commons.apache.org/proper/commons-configuration/userguide/howto_utilities.html#Use_Configuration_in_Spring, we should be able to supply a Configuration to Spring using a ConfigurationPropertySource to tell spring to obtain property values from Commons Configuration2, however it seems that the ConfigurationPropertySource uses getProperty() instead of getString() to supply values to Spring.  This means that the value supplied to string is the literal element from the configuration file and not the value resolved by Apache Commons Configuration2.  This ultimately leads to Spring trying to parse a syntax it doesn't understand.

      When defining values that are resolved from environment properties such as:

      property.custom=${env:CUSTOM_PROPERTY_VALUE}

      Spring will receive the literal value of '${env:CUSTOM_PROPERTY_VALUE}' and ultimately treat this as a default value for a property named 'env' instead of an environment variable reference.   

      I was able to resolve this by updating ConfigurationPropertSource to use `source.getString(name)` instead, then Spring will receive the value Commons Configuration2 has resolved from the environment value and convert it accordingly on it's own.

      Attachments

        Issue Links

          Activity

            People

              Unassigned Unassigned
              kbarlowgw Keith Barlow
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: