Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Modifying a value inside the config file #411

Open
drori200 opened this issue Jan 8, 2023 · 1 comment
Open

Modifying a value inside the config file #411

drori200 opened this issue Jan 8, 2023 · 1 comment
Labels
question Further information is requested

Comments

@drori200
Copy link

drori200 commented Jan 8, 2023

Currently i know how to get a value from the config file using the class. This is all fine but there's the problem of no clear way to edit the values of the config files. Even with the ConfigHolder way there is no straight way to set a new value.

@Gmugra
Copy link
Owner

Gmugra commented Feb 9, 2023

To be honest, the library is based on the assumption that the application does not need to modify the configuration(s).
I.e. the typical scenario is that we find/load configuration(s) at the start and that's it.

We get a specific configuration value as a result of combining (fallback/merging) different sources (including depending, for example, on environment variables). So, the application simply does not know where in the sources this value was.

For example, here is an example from the documentation:

MyConfig myConfig =
    ConfigFactory.builder()
        .setLoadStrategy(LoadStrategy.MERGE)
        .addSource("file:~/myconfig.xml")
        .addSource("classpath:config/myconfig-owner.xml")
        .addSource("jar:file:path/to/some.jar!/path/to/myconfig.properties")
        .addSource("https://somewhere.com/myconfig.toml")
        .addSource("file:./myconfig.json")
        .addSource("file:./myconfig.yaml")
        .build()
        .create(MyConfig.class);

Here we have 6 merged sources, and MyConfig instance just does not know where the particular value in a particular case came from.

Thus, the wish to save the changed configuration somewhere faces the problem: where?
In which of the many sources should the change be saved?
Especially considering that the source may be read-only. (E.g. environment variable cannot be modified from Java application, but can be read and can be configuration source -> loader system:env)

Thus, the back-synchronization of the changed configuration values is not a simple problem, which the library does not solve in any way for the moment.

Exists plan to add kind of such feature: #305
But, to tell the truth, i still not 100% sure is this feature has real value or not: low priority at the moment.

@Gmugra Gmugra added the question Further information is requested label Feb 9, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants