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

PropertiesConfiguration.save() doesn't persist properties added through a DataConfiguration

    XMLWordPrintableJSON

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Critical
    • Resolution: Fixed
    • Affects Version/s: 1.5
    • Fix Version/s: 1.6
    • Component/s: None
    • Labels:
      None

      Description

      There is a regression in Commons Configuration with PropertiesConfiguration wrapped into a DataConfiguration. The properties added through a DataConfiguration aren't persisted when the configuration is saved, but they can be queried normally. Commons Configuration 1.4 wasn't affected by this issue.

      The following test fails on the last assertion :

      public void testSaveWithDataConfiguration() throws ConfigurationException
      {
          File file = new File("target/testsave.properties");
          if (file.exists()) {
              assertTrue(file.delete());
          }
      
          PropertiesConfiguration config = new PropertiesConfiguration(file);
      
          DataConfiguration dataConfig = new DataConfiguration(config);
      
          dataConfig.setProperty("foo", "bar");
          assertEquals("bar", config.getProperty("foo"));
          config.save();
      
          // reload the file
          PropertiesConfiguration config2 = new PropertiesConfiguration(file);
          assertFalse("empty configuration", config2.isEmpty());
      }
      

        Attachments

          Activity

            People

            • Assignee:
              oheger Oliver Heger
              Reporter:
              ebourg Emmanuel Bourg
            • Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: