commons-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Bruno P. Kinoshita (JIRA)" <>
Subject [jira] [Commented] (CONFIGURATION-684) YAMLConfiguration keys with double dots
Date Sat, 23 Dec 2017 22:39:06 GMT


Bruno P. Kinoshita commented on CONFIGURATION-684:

Hmm. Good point []. [~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.


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:
>             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();
> 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

View raw message