Uploaded image for project: 'Commons Configuration'
  1. Commons Configuration
  2. CONFIGURATION-460

reloadStrategy does not work for files inside <additional> tag using DefaultConfigurationBuilder

    XMLWordPrintableJSON

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: 1.6
    • Fix Version/s: 1.7
    • Component/s: File reloading
    • Labels:
      None
    • Environment:

      Linux x86_64

      Description

      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

        Attachments

          Activity

            People

            • Assignee:
              oheger Oliver Heger
              Reporter:
              azfarkazmi Azfar Kazmi
            • Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: