[
https://issues.apache.org/jira/browse/CONFIGURATION-293?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_12521907
]
Wesley Miaw commented on CONFIGURATION-293:
-------------------------------------------
Yeah. I looked into removeNode() and the code makes sense. I just tried again
and it works, unless you have the following set up. I'll attach the
bug-config.xml and the two files it tries to load up as well. (This is a
CombinedConfiguration; I can only make this happen with the
CombinedConfiguration, it works fine if either of the two files mentioned in
bug-config.xml loses its inner-most definition (i.e. bug-override.xml only has
<a></a> or bug-test.properties is empty).
final String prefix = "a.b.c";
public void clearTree() throws ConfigurationException {
final URL xml =
this.getClass().getClassLoader().getResource("bug-config.xml");
final DefaultConfigurationBuilder builder = new
DefaultConfigurationBuilder(xml);
final CombinedConfiguration config =
(CombinedConfiguration)builder.getConfiguration(true);
config.addProperty(prefix, "c");
config.addProperty(prefix + ".d", "d");
config.addProperty(prefix + ".d.e", "e");
config.clearTree(prefix);
assert !config.containsKey(prefix + ".d") : "Sub property not
removed";
assert !config.containsKey(prefix) : "Property not removed";
}
> HierarchicalConfiguration.clearTree() does not remove named property
> --------------------------------------------------------------------
>
> Key: CONFIGURATION-293
> URL: https://issues.apache.org/jira/browse/CONFIGURATION-293
> Project: Commons Configuration
> Issue Type: Bug
> Affects Versions: 1.4
> Reporter: Wesley Miaw
>
> HierarchicalConfiguration.clearTree(String) calls
> HierarchicalConfiguration.removeNode(ConfigurationNode) which removes nothing
> if the passed in ConfigurationNode has no parent. Having no parent is true of
> nodes that have the root for their parent (it seems to me) as well as for
> nodes that have no properties defined "above" them. Here is an example:
> config.addProperty("a.b.c", "c");
> config.addProperty("a.b.c.d", "d");
> config.addProperty("a.b.c.d.e", "e");
> The following sequence of calls will fail:
> config.clearTree("a.b.c");
> assert config.containsKey("a.b.c") == false;
> The following sequence of calls will succeed:
> config.clearTree("a.b.c.d");
> assert config.containsKey("a.b.c.d") == false;
> assert config.containsKey("a.b.c.d.e") == false;
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.