You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@commons.apache.org by "Gary D. Gregory (Jira)" <ji...@apache.org> on 2023/07/10 19:29:00 UTC

[jira] [Commented] (CONFIGURATION-834) ConfirgurationPropertySource doesn't supply resolved values.

    [ https://issues.apache.org/jira/browse/CONFIGURATION-834?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17741749#comment-17741749 ] 

Gary D. Gregory commented on CONFIGURATION-834:
-----------------------------------------------

Hi [~kbarlowgw] 

Thank you for your report.

Would you please create a PR on GitHub with a unit test?

> ConfirgurationPropertySource doesn't supply resolved values.
> ------------------------------------------------------------
>
>                 Key: CONFIGURATION-834
>                 URL: https://issues.apache.org/jira/browse/CONFIGURATION-834
>             Project: Commons Configuration
>          Issue Type: Bug
>          Components: Interpolation, Type conversion
>    Affects Versions: 2.8.0
>            Reporter: Keith Barlow
>            Priority: Minor
>
> 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:
> {code:java}
> property.custom=${env:CUSTOM_PROPERTY_VALUE}{code}
> 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.



--
This message was sent by Atlassian Jira
(v8.20.10#820010)