[ 
https://issues.apache.org/jira/browse/CONFIGURATION-684?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16301678#comment-16301678
 ] 

Oliver Heger commented on CONFIGURATION-684:
--------------------------------------------

The documentation is still available for 2.x; it can be found here:
http://commons.apache.org/proper/commons-configuration/userguide/howto_hierarchical.html#Escaping_special_characters

Maybe it is confusing and could be better documented, but the behavior is 
actually expected. As described in the referenced section of the documentation, 
you have to duplicate dots in order to escape them, so that properties with 
dots in their names can be accessed correctly.  The iterator returned by 
getKeys() takes this into account, i.e. it returns keys in an escaped form, so 
that they can be used directly to query properties. Otherwise, you would have 
very strange results: keys obtained from the configuration would be 
unresolvable.

> 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)

Reply via email to