Issue Details (XML | Word | Printable)

Key: CONFIGURATION-334
Type: Bug Bug
Status: Closed Closed
Resolution: Fixed
Priority: Minor Minor
Assignee: Unassigned
Reporter: Oliver Heger
Votes: 0
Watchers: 0
Operations

If you were logged in you would be able to see more operations.
Commons Configuration

Inconsistent parent nodes in HierarchicalConfiguration when using setRootNode()

Created: 11/Aug/08 07:14 PM   Updated: 22/Aug/09 07:36 PM
Return to search
Component/s: None
Affects Version/s: 1.5
Fix Version/s: 1.6

Time Tracking:
Not Specified

Resolution Date: 12/Aug/08 09:41 AM


 Description  « Hide
HierarchicalConfiguration allows setting a root node explicitly using either setRootNode() or setRoot(). The latter exists for backwards compatibility only and operates on the type HierarchicalConfiguration.Node rather than ConfigurationNode. To support a corresponding getRoot() method a new instance of HierarchicalConfiguration.Node is created, and the child nodes of the root node are added to it. Thus these nodes become child nodes of this new node.

If now addProperty() is called for adding new properties to the configuration, the nodes created for the new properties are added to the node passed to the setRootNode() method. So they have a different parent node than the existing nodes.

As long as only methods of the Configuration interface are used for querying or manipulating the configuration, this does not seem to have any strange effects. But when working with the nodes directly it is certainly confusing.



 All   Comments   Work Log   Change History   Subversion Commits      Sort Order: Ascending order - Click to sort in descending order
Repository Revision Date User Message
ASF #685103 Tue Aug 12 09:34:57 UTC 2008 oheger CONFIGURATION-334: Made handling of parent nodes more consistent.
Files Changed
MODIFY /commons/proper/configuration/trunk/xdocs/changes.xml
MODIFY /commons/proper/configuration/trunk/src/java/org/apache/commons/configuration/HierarchicalConfiguration.java
MODIFY /commons/proper/configuration/trunk/src/test/org/apache/commons/configuration/TestHierarchicalConfiguration.java

Oliver Heger added a comment - 12/Aug/08 09:41 AM
A fix was applied, which changes the following:
  • If setRootNode() is called, the parent node of the child nodes of the new root are not changed. So they remain children of the root rather than being added to the HierarchicalConfiguration.Node that is created for reasons of backwards compatibility.
  • The node returned by getRoot() is not created when setRootNode() is called, but it will be created each time getRoot() is called. Thus it is guaranteed that it is up-to-date and points to a life snapshot of the node structure in this configuration.

Oliver Heger made changes - 12/Aug/08 09:41 AM
Field Original Value New Value
Resolution Fixed [ 1 ]
Status Open [ 1 ] Resolved [ 5 ]
Fix Version/s 1.6 [ 12312450 ]
Oliver Heger made changes - 22/Aug/09 07:36 PM
Status Resolved [ 5 ] Closed [ 6 ]