Details
-
Bug
-
Status: Open
-
Minor
-
Resolution: Unresolved
-
0.4-incubating
-
None
-
None
Description
When using this Yaml file as property source
key1: value1 key2: key2_1: value2_1 key2_2: value2_2
Configuration.getProperties() returns a map in which the keys only contain the last part of the Yaml path:
PropertySource ps = ConfigurationFormats.getInstance().createPropertySource( Thread.currentThread().getContextClassLoader().getResource("myFileConfig.yaml"), new YAMLFormat()); Configuration cfg = new DefaultConfigurationBuilder().addPropertySources(ps).build(); cfg.getProperties().forEach((key, value) -> { if (!key.startsWith("_")) System.out.println(key + " -> " + value); });
prints
key1 -> value1 key2_1 -> value2_1 key2_2 -> value2_2
The equivalent code for version 0.3-incubating
PropertySource ps = ConfigurationFormats.createPropertySource( Thread.currentThread().getContextClassLoader().getResource("myFileConfig.yaml"), new YAMLFormat()); Configuration cfg = ConfigurationProvider.createConfiguration( ConfigurationProvider.getConfigurationContextBuilder().addPropertySources(ps).build()); cfg.getProperties().forEach((key, value) -> { if (!key.startsWith("_")) System.out.println(key + " -> " + value); });
returns the full keys (e.g. "key2.key2_1" instead of "key2_1"):
key1 -> value1 key2.key2_2 -> value2_2 key2.key2_1 -> value2_1
Using the full keys to get the values from the configuration works in both versions:
cfg.get("key2.key2_1")
returns the correct value in both Tamaya versions.
This issue makes it difficult to iterate over all keys of the configuration, for example for logging or debugging purposes.