[ https://issues.apache.org/jira/browse/CONFIGURATION-831?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17941589#comment-17941589 ]
Gary D. Gregory commented on CONFIGURATION-831: ----------------------------------------------- We already support a syntax to provide a value when a key is absent, see {{{}org.apache.commons.configuration2.interpol.TestConfigurationInterpolator.testInterpolationSingleVariableDefaultValue(){}}}: {code:java} assertEquals("42", interpolator.interpolate("${I_am_not_defined:-42}")); {code} > Unresolved (non-existend) environment variables should return null > ------------------------------------------------------------------ > > Key: CONFIGURATION-831 > URL: https://issues.apache.org/jira/browse/CONFIGURATION-831 > Project: Commons Configuration > Issue Type: New Feature > Components: Interpolation > Affects Versions: 2.9.0 > Reporter: Wojtek > Priority: Minor > > Currently Interpolation of environment variables > (https://commons.apache.org/proper/commons-configuration/userguide/howto_basicfeatures.html#Variable_Interpolation) > return un-interpolated string if the environment variable doesn't exists at > all. > It would be very convenient and (I feel) more consistent if, in that case, > 'null' would be returned. > > Alternatively, option to specify default if the variable doesn't exist would > also work. > I.e. something along the lines: > ``` > ${env:JAVA_HOME:<default value>} > ``` > > From my experiments, even if we try to register custom interpolator it's not > possible to explicitly return `null` from it. -- This message was sent by Atlassian Jira (v8.20.10#820010)