[
https://issues.apache.org/jira/browse/CONFIGURATION-332?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]
Oliver Heger resolved CONFIGURATION-332.
----------------------------------------
Resolution: Fixed
There is a problem with DataConfiguration that it does not implement some
methods of the Configuration interface by delegating to the wrapped
configuration (as a decorator should do), but uses the default implementations
inherited from AbstractConfiguration. This can cause unpredictable results if
the wrapped configuration overrides one of these methods.
Maybe in 2.0 we should consider reimplementing this class as a true decorator.
To be safe it should not extend AbstractConfiguration, but implement all
methods required by the Configuration interface manually - delegating to the
wrapped configuration.
> PropertiesConfiguration.save() doesn't persist properties added through a
> DataConfiguration
> -------------------------------------------------------------------------------------------
>
> Key: CONFIGURATION-332
> URL: https://issues.apache.org/jira/browse/CONFIGURATION-332
> Project: Commons Configuration
> Issue Type: Bug
> Affects Versions: 1.5
> Reporter: Emmanuel Bourg
> Assignee: Oliver Heger
> Priority: Critical
> Fix For: 1.6
>
>
> 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 :
> {code}
> 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());
> }
> {code}
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.