[
https://issues.apache.org/jira/browse/CONFIGURATION-684?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16302606#comment-16302606
]
Bruno P. Kinoshita commented on CONFIGURATION-684:
--------------------------------------------------
Hmm. Good point [[email protected]]. [~fabienrenaud], not too sure
about disabling it completely, as it would impact other users that have built
their software on top of the premise that dots were escaped.
I don't have the need for this change right now, but perhaps users that have
YAML configuration files from other frameworks/tools with dots in the keys
could be affected by this issue.
There are some tools (Ansible, Jenkins, Openshift, SpringBoot, etc) that
support YAML and may use dots in the keys. I suspect users from these tools
could report problems some day with this default behaviour.
*
https://github.com/spring-projects/spring-boot/blob/8f793eaf33cc312935fc69b3591bf2aa55c63275/spring-boot-project/spring-boot/src/test/resources/activeprofilerepro.yml
*
https://github.com/khoubyari/spring-boot-rest-example/blob/c8c6a745ed7c2772d26cfb24a46f17c230eedcfe/src/main/resources/application.yml
*
https://github.com/openshift/origin/blob/d017a2b159a44ae6860696caa3f9a88261e7b82a/examples/jenkins/pipeline/bluegreen-pipeline.yaml
So I would be pending towards i) modifying the keys parsing just for YAML,
allowing dots, and then ii) updating the documentation explaining that YAML
supports dots in the keys, but not the other formats.
One issue that we could have, however, is when mixing configurations from
YAML/XML/ini/etc. Not sure if there could be a case where a key read from a
YAML file is mixed with keys from other sources, and for some reason it results
in an error...
Not in a hurry to get it fixed, so happy to wait others to review this issue
and vote on these solutions or others, or just comment their point of view.
> YAMLConfiguration keys with double dots
> ---------------------------------------
>
> Key: CONFIGURATION-684
> URL: https://issues.apache.org/jira/browse/CONFIGURATION-684
> Project: Commons Configuration
> Issue Type: Bug
> Reporter: Fabien Renaud
>
> h2. Issue
> Loading a YAML configuration with dotted keys causes dots to be duplicated in
> the keys of the YAMLConfiguration object.
> h2. Repro
> 100% repro:
> file.yml:
> {code}some.key.with.dots: 123{code}
> {code}
> 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);
> }
> }
> {code}
> prints
> {code}some..key..with..dots
> ---
> some..key..with..dots
> {code}
> That is a serious bug for a configuration system. The issue may easily go
> untested for some keys and only reveal itself on production.
--
This message was sent by Atlassian JIRA
(v6.4.14#64029)