You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@commons.apache.org by "Oliver Heger (JIRA)" <ji...@apache.org> on 2016/12/19 17:27:58 UTC
[jira] [Commented] (CONFIGURATION-646) autoSave and manual save
behave differently
[ https://issues.apache.org/jira/browse/CONFIGURATION-646?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15761765#comment-15761765 ]
Oliver Heger commented on CONFIGURATION-646:
--------------------------------------------
Thanks for the report and the test case. I will have a look in a few days.
> autoSave and manual save behave differently
> -------------------------------------------
>
> Key: CONFIGURATION-646
> URL: https://issues.apache.org/jira/browse/CONFIGURATION-646
> Project: Commons Configuration
> Issue Type: Bug
> Affects Versions: 2.1
> Reporter: Christian Rudolph
> Priority: Minor
>
> Using {{builder.autoSave(true)}} behaves differently than {{builder.save()}} to the aspect that {{builder.autoSave(true)}} doesn't write newly added properties to the assigned config file.
> I've set up a minimal example using only two dependencies:
> commons-beanutils:commons-beanutils:1.9.3 (runtime)
> org.apache.commons:commons-configuration2:2.1.0 (compiletime)
> {code}
> public class Main {
> public static void main(String... args) {
> Parameters params = new Parameters();
> File propertiesFile = new File("conf.properties");
> FileBasedConfigurationBuilder<PropertiesConfiguration> builder =
> new FileBasedConfigurationBuilder<>(PropertiesConfiguration.class)
> .configure(params.fileBased().setFile(propertiesFile));
> builder.setAutoSave(true);
> try {
> PropertiesConfiguration config = builder.getConfiguration();
> config.setProperty("foo", "bar");
> // builder.save();
> } catch (ConfigurationException e) {
> e.printStackTrace();
> }
> }
> }
> {code}
> This is mainly like the example from the documentation for filebased configurations.
> {{conf.properties}} exists and is empty. With the {{builder.save}} line commented out, the file remains empty. Uncommenting this line results in the expected behavior.
> I debugged a bit an saw that the property isn't added to the {{PropertiesConfigurationLayout}} in the first case.
--
This message was sent by Atlassian JIRA
(v6.3.4#6332)