commons-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Fabien Nisol (JIRA)" <>
Subject [jira] [Created] (CONFIGURATION-441) CompositeConfiguration does not resolve referenced properties correctly
Date Wed, 30 Mar 2011 18:20:05 GMT
CompositeConfiguration does not resolve referenced properties correctly

                 Key: CONFIGURATION-441
             Project: Commons Configuration
          Issue Type: Bug
          Components: Interpolation
    Affects Versions: 1.5
         Environment: all
            Reporter: Fabien Nisol

Imagine a composite configuration consisting of 

config_x : configuration one

config_y : configuration two${}

When getProperty() is called on a CompositeConfiguration, property interpolation does not
work if a property in config_x refers to a property in config_y, in the example,
won't translate into "one"

This seems to be caused by the getProperty() implementation of CompositeConfiguration

     * Read property from underlying composite
     * @param key key to use for mapping
     * @return object associated with the given configuration key.
    public Object getProperty(String key)
        Configuration firstMatchingConfiguration = null;
        for (Iterator i = configList.iterator(); i.hasNext();)
            Configuration config = (Configuration);
            if (config.containsKey(key))
                firstMatchingConfiguration = config;

        if (firstMatchingConfiguration != null)
            return firstMatchingConfiguration.getProperty(key);
            return null;

The methods finds the first configuration containing the key, and delegates the call to that
particular configuration.

A possible fix would be to try interpolation against every configuration until an interpolation

This message is automatically generated by JIRA.
For more information on JIRA, see:

View raw message