Details
-
Bug
-
Status: Closed
-
Major
-
Resolution: Not A Problem
-
None
-
None
-
None
Description
Issue
Loading a YAML configuration with dotted keys causes dots to be duplicated in the keys of the YAMLConfiguration object.
Repro
100% repro:
file.yml:
some.key.with.dots: 123
package foo; import org.apache.commons.configuration2.YAMLConfiguration; import org.apache.commons.configuration2.builder.FileBasedConfigurationBuilder; import org.apache.commons.configuration2.builder.fluent.Parameters; import org.apache.commons.configuration2.ex.ConfigurationException; public class App { public static void main(String[] args) throws ConfigurationException { Parameters params = new Parameters(); FileBasedConfigurationBuilder<YAMLConfiguration> builder1 = new FileBasedConfigurationBuilder<>(YAMLConfiguration.class) .configure(params.fileBased().setFileName("file.yml")); YAMLConfiguration conf = builder1.getConfiguration(); conf.getKeys().forEachRemaining(System.out::println); System.out.println("---"); YAMLConfiguration yaml = new YAMLConfiguration(); yaml.read(new InputStreamReader(ClassLoader.getSystemResourceAsStream("file.yml"))); yaml.getKeys().forEachRemaining(System.out::println); } }
prints
some..key..with..dots --- some..key..with..dots
That is a serious bug for a configuration system. The issue may easily go untested for some keys and only reveal itself on production.