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

Oliver Heger commented on CONFIGURATION-460:
--------------------------------------------

The problem is probably caused by the structure of the combined configuration 
produced by {{DefaultConfigurationBuilder}}:
* There is one {{CombinedConfiguration}} which stores all properties. It is 
configured by properties in the _result_ section.
* For configuration sources declared in the _additional_ section another 
{{CombinedConfiguration}} is created and added to the first 
{{CombinedConfiguration}}. This configuration, however, is currently not fully 
initialized. Especially the _forceReloadCheck_ property is not set. Therefore 
reloads are not detected.

A fix for this issue has to ensure that some of the properties defined for the 
result configuration are also set for the configuration for the additional 
sources.

> reloadStrategy does not work for files inside <additional> tag using 
> DefaultConfigurationBuilder
> ------------------------------------------------------------------------------------------------
>
>                 Key: CONFIGURATION-460
>                 URL: https://issues.apache.org/jira/browse/CONFIGURATION-460
>             Project: Commons Configuration
>          Issue Type: Bug
>          Components: File reloading
>    Affects Versions: 1.6
>         Environment: Linux x86_64
>            Reporter: Azfar Kazmi
>
> In the configuration file that DefaultConfigurationBuilder reads to build a 
> CombinedConfiguration, it's possible to include configuration file either 
> inside <override> or <additional> xml elements.
> Each such declaration, of a file, allows a realodStrategy to be specified 
> (see example below). It appears that the reload occurs only for the files 
> inside <override> and not for the ones inside <additional>.
> Example:
> <configuration>
>   <header>
>     <result forceReloadCheck="true">
>       <expressionEngine 
> config-class="org.apache.commons.configuration.tree.xpath.XPathExpressionEngine"/>
>     </result>
>   </header>
>   <override>
>     <properties fileName="user.properties" config-optional="true">
>       <reloadingStrategy refreshDelay="100"
>                          
> config-class="org.apache.commons.configuration.reloading.FileChangedReloadingStrategy"/>
>     </properties>
>   </override>
>   <additional>
>     <properties fileName="application.properties">
>       <reloadingStrategy refreshDelay="100"
>                          
> config-class="org.apache.commons.configuration.reloading.FileChangedReloadingStrategy"/>
>     </properties>
>   </additional>
> </configuration>
> In above example, both user.properties and application.properties are 
> supposed to reload upon change. However, as tested by the following code, one 
> user.properties gets reloaded:
>               DefaultConfigurationBuilder dcb = new 
> DefaultConfigurationBuilder("example.xml");
>               Configuration conf = dcb.getConfiguration();
>               System.out.println("user: " + conf.getBoolean("user"));
>               System.out.println("application: " + 
> conf.getBoolean("application"));
>               System.out.println("Change files and then press  to 
> continue...");
>               System.in.read();
>               
>               System.out.println("user: " + conf.getBoolean("user"));
>               System.out.println("application: " + 
> conf.getBoolean("application"));
> Output from above code:
> user: true
> application: true
> Change files and then press  to continue...
> 0 [main] INFO org.apache.commons.configuration.PropertiesConfiguration  - 
> Reloading configuration. URL is file:<snipped>/user.properties
> user: false
> application: true

--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

Reply via email to