commons-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Pavel Gavrilov (JIRA)" <j...@apache.org>
Subject [jira] [Created] (CONFIGURATION-699) HierarchicalConfiguration childConfigurationsAt(String key) method not throws exception if key is not found in XML file
Date Wed, 25 Apr 2018 14:47:00 GMT
Pavel Gavrilov created CONFIGURATION-699:
--------------------------------------------

             Summary: 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


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

Mime
View raw message