You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
its a bug, when you make map of string and nested section, and soon add new value to nested section, the config is reset
A248
changed the title
Reset config on new options
Entire map of nested sections is reset to default when one section is missing a required key
Dec 31, 2021
This is a bug, but it is a design bug rather than a functional bug. The fix is more difficult than it seems.
When you load the configuration with fallback-to-default behavior, what really happens is default values are created using ConfigurationFactory#loadDefaults. These defaults are then provided to the #load method as auxiliary values (auxiliary values are fallback values). When a configuration option is processed, we have access only to the auxiliary value of the entire configuration option.
Therefore, in the current design, we have only access to the Map<String, YourConfSection> default value but not the YourConfSection default value. Solving this would require a design rework. Possible options:
Use a node system of ConfigEntry and ConfigValue<T> objects, which can provide additional metadata. This will happen at some point, but it would be a breaking change, and so must either wait until 2.0 or be established with backwards compatibility in mind.
Creating another #load method on ConfigurationFactory which provides more dynamic handling of auxiliary values, such that they could be requested on-demand from different sources.
Various "hacks" are possible, including adding a toggle to ConfigurationOptions to provide special behavior for your situation.
The config is reset when we put a nested section in a map
The text was updated successfully, but these errors were encountered: