You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tamaya.apache.org by "Philipp Ottlinger (Jira)" <ji...@apache.org> on 2020/11/29 20:34:00 UTC

[jira] [Commented] (TAMAYA-415) Configuration.getProperties() returns only last part of the keys when property source is Yaml

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

Philipp Ottlinger commented on TAMAYA-415:
------------------------------------------

[~werner288] thanks for your interest in Tamaya.

 

I'm sorry to report that the project is about to be retired .... and will move back to a place away from ASF at Github.

> Configuration.getProperties() returns only last part of the keys when property source is Yaml
> ---------------------------------------------------------------------------------------------
>
>                 Key: TAMAYA-415
>                 URL: https://issues.apache.org/jira/browse/TAMAYA-415
>             Project: Tamaya
>          Issue Type: Bug
>          Components: Core, Extensions
>    Affects Versions: 0.4-incubating
>            Reporter: Werner Heine
>            Priority: Minor
>
> When using this Yaml file as property source
> {code:yaml}
> key1: value1
> key2:
>   key2_1: value2_1
>   key2_2: value2_2
> {code}
> Configuration.getProperties() returns a map in which the keys only contain the last part of the Yaml path:
> {code:java}
> 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);
> });
> {code}
> prints
> {noformat}
> key1 -> value1
> key2_1 -> value2_1
> key2_2 -> value2_2
> {noformat}
> The equivalent code for version 0.3-incubating
> {code:java}
> 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);
> });
> {code}
> returns the full keys (e.g. "key2.key2_1" instead of "key2_1"):
> {noformat}
> key1 -> value1
> key2.key2_2 -> value2_2
> key2.key2_1 -> value2_1
> {noformat}
>  
>  Using the full keys to get the values from the configuration works in both versions:
> {code:java}
> cfg.get("key2.key2_1")
> {code}
> 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.
>   



--
This message was sent by Atlassian Jira
(v8.3.4#803005)