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

CompositeConfiguration delivers value from wrong child

    XMLWordPrintableJSON

    Details

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

      Description

      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"

        Attachments

          Activity

            People

            • Assignee:
              oheger Oliver Heger
              Reporter:
              jwesely Joerg Wesely
            • Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: