CompositeConfiguration delivers value from wrong child
------------------------------------------------------

                 Key: CONFIGURATION-471
                 URL: https://issues.apache.org/jira/browse/CONFIGURATION-471
             Project: Commons Configuration
          Issue Type: Bug
          Components: File reloading
    Affects Versions: 1.7
            Reporter: Joerg Wesely


I create a composite configuration with two PropertyConfigurations: a user 
configuration and a default configuration, with the userConfiguration as 
inMemoryConfiguration.
If both configurations contain the same key, the value from 
defaultConfiguration is returned although the user configuration was added 
first. If no inMemoryConfiguration is specified, it's working ok:

Configuration defaultConf = new PropertiesConfiguration();
defaultConf.addProperty("prop1", "fromDefaultConfig");
        
Configuration userConf = new PropertiesConfiguration();
userConf.addProperty("prop1", "fromUserConfig");
        
CompositeConfiguration noMemoryConfig = new CompositeConfiguration();
noMemoryConfig.addConfiguration(userConf);
noMemoryConfig.addConfiguration(defaultConf);
System.out.println("noMemoryConfig: " + noMemoryConfig.getString("prop1")); // 
Shows "fromUserConfig" 
        
CompositeConfiguration withMemoryConfig = new CompositeConfiguration(userConf);
withMemoryConfig.addConfiguration(userConf);
withMemoryConfig.addConfiguration(defaultConf);
System.out.println("withMemoryConfig: " + withMemoryConfig.getString("prop1")); 
// Shows "fromDefaultConfig"

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: 
https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

Reply via email to