Details
-
Bug
-
Status: Resolved
-
Major
-
Resolution: Fixed
-
1.1
-
None
-
None
-
None
-
Operating System: other
Platform: Other
-
34410
Description
Setting a PropertiesConfiguration autoSave=true via a ConfigurationFactory can
cause the underlying properties file to be completely overwritten.
Example:
config.xml:
<?xml version="1.0" encoding="ISO-8859-1" ?>
<configuration>
<properties fileName="application.properties" />
<properties fileName="ui.properties" autoSave="true"/>
</configuration>
application.properties:
application.name=Test App
application.version = 0.01
application.title = ${application.name} V${application.version}
ui.properties:
ui.test="stuff here"
Execute the code:
ConfigurationFactory factory = new ConfigurationFactory();
URL configURL = getClass().getResource("/config.xml");
factory.setConfigurationURL(configURL);
try
catch (ConfigurationException e)
{ e.printStackTrace(); }Program output:
12/04/2005 10:24:00
org.apache.commons.configuration.ConfigurationFactory$FileConfigurationFactory
createObject
INFO: Trying to load configuration application.properties
12/04/2005 10:24:00
org.apache.commons.configuration.ConfigurationFactory$FileConfigurationFactory
createObject
INFO: Trying to load configuration ui.properties
Test App V0.01
"stuff here"
will this get saved ?
After execution
---------------
application.properties:
application.name=Test App
application.version = 0.01
application.title = ${application.name} V${application.version}
ui.properties:
- written by PropertiesConfiguration
- Tue Apr 12 10:24:00 EST 2005
NOTE ui.test doesn't appear with either the old value or the modified one.