You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@commons.apache.org by "Pavel Gavrilov (JIRA)" <ji...@apache.org> on 2018/04/25 14:48:00 UTC

[jira] [Updated] (CONFIGURATION-699) HierarchicalConfiguration childConfigurationsAt(String key) method not throws exception if key is not found in XML file

     [ https://issues.apache.org/jira/browse/CONFIGURATION-699?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Pavel Gavrilov updated CONFIGURATION-699:
-----------------------------------------
    Description: 
{code:java}
List<HierarchicalConfiguration<ImmutableNode>> hierarchicalConfigurations = configuration.childConfigurationsAt("key");
{code}
will return empty list if "key" is not in xml file, but
{code:java}
HierarchicalConfiguration<ImmutableNode> nodeHierarchicalConfiguration = configuration.configurationAt("key");
{code}
will throw ConfigurationRuntimeException.

So if you don't get an exception, you may think that there is not nodes under "key" (, but actually xml file not contains "key" (is not valid). To avoid it you have to call in try/catch
{code:java}
configuration.configurationAt("key"){code}
first, that may produce an exception and then use
{code:java}
configuration.childConfigurationsAt("key");{code}

  was:
{code:java}
List<HierarchicalConfiguration<ImmutableNode>> hierarchicalConfigurations = configuration.childConfigurationsAt("key");
{code}
will return empty list if key is not in xml file, but
{code:java}
HierarchicalConfiguration<ImmutableNode> nodeHierarchicalConfiguration = configuration.configurationAt("key");
{code}
will throw ConfigurationRuntimeException.

So if you don't get an exception, you may think that there is not nodes under "key" (, but actually xml file not contains "key" (is not valid). To avoid it you have to call in try/catch
{code:java}
configuration.configurationAt("key"){code}
first, that may produce an exception and then use
{code:java}
configuration.childConfigurationsAt("key");{code}


> HierarchicalConfiguration childConfigurationsAt(String key) method not throws exception if key is not found in XML file
> -----------------------------------------------------------------------------------------------------------------------
>
>                 Key: CONFIGURATION-699
>                 URL: https://issues.apache.org/jira/browse/CONFIGURATION-699
>             Project: Commons Configuration
>          Issue Type: Bug
>            Reporter: Pavel Gavrilov
>            Priority: Major
>
> {code:java}
> List<HierarchicalConfiguration<ImmutableNode>> hierarchicalConfigurations = configuration.childConfigurationsAt("key");
> {code}
> will return empty list if "key" is not in xml file, but
> {code:java}
> HierarchicalConfiguration<ImmutableNode> nodeHierarchicalConfiguration = configuration.configurationAt("key");
> {code}
> will throw ConfigurationRuntimeException.
> So if you don't get an exception, you may think that there is not nodes under "key" (, but actually xml file not contains "key" (is not valid). To avoid it you have to call in try/catch
> {code:java}
> configuration.configurationAt("key"){code}
> first, that may produce an exception and then use
> {code:java}
> configuration.childConfigurationsAt("key");{code}



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)