You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@commons.apache.org by "Oliver Heger (Resolved) (JIRA)" <ji...@apache.org> on 2012/01/18 21:56:41 UTC

[jira] [Resolved] (CONFIGURATION-471) CompositeConfiguration delivers value from wrong child

     [ https://issues.apache.org/jira/browse/CONFIGURATION-471?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Oliver Heger resolved CONFIGURATION-471.
----------------------------------------

       Resolution: Fixed
    Fix Version/s: 1.8

An overloaded version of {{addConfiguration()}} was added which expects an additional boolean parameter. If set to *true*, the newly added configuration becomes the in-memory configuration.

When used this way, no re-ordering of child configurations is done. This solves the problem described in this ticket: Just create a {{CompositeConfiguration}} using the default constructor, and then add the child configurations in the desired order. For the child configuration which should become the in-memory configuration set the flag to *true*. Then everything should work as desired.

The new functionality is available in subversion in revision 1233058.
                
> 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
>            Assignee: Oliver Heger
>             Fix For: 1.8
>
>
> 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