[ https://issues.apache.org/jira/browse/CONFIGURATION-89?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Emmanuel Bourg updated CONFIGURATION-89: ---------------------------------------- Fix Version/s: 1.2 > [configuration] Setting the reloading strategy to > FileChangedReloadingStrategy erases entire configuration > ---------------------------------------------------------------------------------------------------------- > > Key: CONFIGURATION-89 > URL: https://issues.apache.org/jira/browse/CONFIGURATION-89 > Project: Commons Configuration > Issue Type: Bug > Affects Versions: 1.1 > Environment: Operating System: Windows XP > Platform: PC > Reporter: Blaine R Southam > Priority: Critical > Fix For: 1.2 > > Attachments: AbstractFileConfiguration.diff, > TestFileConfiguration.diff > > > 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")); > } -- This message is automatically generated by JIRA. - You can reply to this email to add a comment to the issue online. --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]