You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@commons.apache.org by bu...@apache.org on 2005/04/13 18:26:21 UTC
DO NOT REPLY [Bug 34441] New: -
Setting Configuration Reloading Strategy to FileChangedReloadingStrategy erases entire configuration
DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG�
RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
<http://issues.apache.org/bugzilla/show_bug.cgi?id=34441>.
ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND�
INSERTED IN THE BUG DATABASE.
http://issues.apache.org/bugzilla/show_bug.cgi?id=34441
Summary: Setting Configuration Reloading Strategy to
FileChangedReloadingStrategy erases entire configuration
Product: Commons
Version: 1.1 Final
Platform: PC
OS/Version: Windows XP
Status: NEW
Severity: critical
Priority: P2
Component: Configuration
AssignedTo: commons-dev@jakarta.apache.org
ReportedBy: bsoutham@gmail.com
When setting a PropertiesConfiguration reloading strategy to
FileChangedReloadingStrategy - the entire configuration is erased.
The problem is that when the FileChangedReloadingStrategy is set, the
configuration file is erased and then reloaded and then written out.
The file is erased in AbstractFileConfiguration.save(File) when a new
FileOutputStream is created. Then in the PropertiesConfiguration.save(Writer)
the call to getKeys() causes a reaload() to occur (which the strategy says needs
to be reloaded because it has been modified). But the saved config file is now
zeroed out by the new file stream, and it is read in as an empty config.
Here is a testcase that exposed this defect:
public void
testPropertiesConfigurationWithFileChangedReloadingStrategyDefect() throws
ConfigurationException, FileNotFoundException, IOException {
FileWriter file = new FileWriter("testfile.properties");
file.write("a=1");
file.close();
FileConfiguration config = new
PropertiesConfiguration("testfile.properties");
config.setAutoSave(true);
config.setReloadingStrategy(new FileChangedReloadingStrategy());
assertEquals("1", config.getString("a"));
config.setProperty("2", "b");
assertEquals("1", config.getString("a"));
}
--
Configure bugmail: http://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug, or are watching the assignee.
---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org