You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@commons.apache.org by "Vasanth Amana (JIRA)" <ji...@apache.org> on 2009/09/14 12:22:57 UTC

[jira] Created: (CONFIGURATION-396) In HierarchicalConfiguration$Node visits the ConfigurationKey points to the parent path in visitAfterChildren call

In HierarchicalConfiguration$Node visits the ConfigurationKey  points to the parent path in visitAfterChildren call
-------------------------------------------------------------------------------------------------------------------

                 Key: CONFIGURATION-396
                 URL: https://issues.apache.org/jira/browse/CONFIGURATION-396
             Project: Commons Configuration
          Issue Type: Bug
    Affects Versions: 1.6
            Reporter: Vasanth Amana


When visiting a child the key is aggregated to have the child node name, and a call to visitBeforeChildren and grandChildren's visits are made.

However, before calling  visitAfterChildren,  the resetting of the key to that of it's parent's, seems inconsistent.

public void visit(NodeVisitor visitor, ConfigurationKey key)
        {
            int length = 0;
            if (key != null)
            {
                length = key.length();
                if (getName() != null)
                {
                    key
                            .append(StringUtils
                                    .replace(
                                            isAttribute() ? ConfigurationKey
                                                    .constructAttributeKey(getName())
                                                    : getName(),
                                            String
                                                    .valueOf(ConfigurationKey.PROPERTY_DELIMITER),
                                            ConfigurationKey.ESCAPED_DELIMITER));
                }
            }

            visitor.visitBeforeChildren(this, key);

            for (Iterator it = getChildren().iterator(); it.hasNext()
                    && !visitor.terminate();)
            {
                ((Node) it.next()).visit(visitor, key);
            }
            for (Iterator it = getAttributes().iterator(); it.hasNext()
                    && !visitor.terminate();)
            {
                ((Node) it.next()).visit(visitor, key);
            }

            if (key != null)
            {
                key.setLength(length);
            }
            visitor.visitAfterChildren(this, key);
        }
    }

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Commented: (CONFIGURATION-396) In HierarchicalConfiguration$Node visits the ConfigurationKey points to the parent path in visitAfterChildren call

Posted by "Oliver Heger (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/CONFIGURATION-396?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12759944#action_12759944 ] 

Oliver Heger commented on CONFIGURATION-396:
--------------------------------------------

You are right, resetting the key before {{visitAfterChildren()}} is inconsistent.

Changing the order of the code fragment you pointed out - so that {{visitAfterChildren()}} is called first and then the key is reset - obviously has no negative side effect. At least, all unit tests keep running. So I think we should change this.

One remark however: The inner {{Node}} and {{NodeVisitor}} classes of {{HierarchicalConfiguration}} exist only for reasons of backwards compatibility. New code should use the corresponding classes in the {{tree}} package, i.e. {{ConfigurationNode}} and {{ConfigurationNodeVisitor}}. The {{ConfigurationNodeVisitor}} interface does not provide a configuration key. This is due to the fact that different expression engines can be set which all can use a specific syntax for their property keys.

> In HierarchicalConfiguration$Node visits the ConfigurationKey  points to the parent path in visitAfterChildren call
> -------------------------------------------------------------------------------------------------------------------
>
>                 Key: CONFIGURATION-396
>                 URL: https://issues.apache.org/jira/browse/CONFIGURATION-396
>             Project: Commons Configuration
>          Issue Type: Bug
>    Affects Versions: 1.6
>            Reporter: Vasanth Amana
>   Original Estimate: 1h
>  Remaining Estimate: 1h
>
> When visiting a child the key is aggregated to have the child node name, and a call to visitBeforeChildren and grandChildren's visits are made.
> However, before calling  visitAfterChildren,  the resetting of the key to that of it's parent's, seems inconsistent.
> Last lines in visit(NodeVisitor visitor, ConfigurationKey key) 
>             if (key != null)
>             {
>                 key.setLength(length);
>             }
>             visitor.visitAfterChildren(this, key);

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Resolved: (CONFIGURATION-396) In HierarchicalConfiguration$Node visits the ConfigurationKey points to the parent path in visitAfterChildren call

Posted by "Oliver Heger (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/CONFIGURATION-396?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Oliver Heger resolved CONFIGURATION-396.
----------------------------------------

       Resolution: Fixed
    Fix Version/s: 1.7

A fix was applied in revision 819395. Thanks for spotting this.

Note: This fix does not apply to the configuration2 branch; here the {{HierarchicalConfiguration.NodeVisitor}} class has been removed.

> In HierarchicalConfiguration$Node visits the ConfigurationKey  points to the parent path in visitAfterChildren call
> -------------------------------------------------------------------------------------------------------------------
>
>                 Key: CONFIGURATION-396
>                 URL: https://issues.apache.org/jira/browse/CONFIGURATION-396
>             Project: Commons Configuration
>          Issue Type: Bug
>    Affects Versions: 1.6
>            Reporter: Vasanth Amana
>            Assignee: Oliver Heger
>             Fix For: 1.7
>
>   Original Estimate: 1h
>  Remaining Estimate: 1h
>
> When visiting a child the key is aggregated to have the child node name, and a call to visitBeforeChildren and grandChildren's visits are made.
> However, before calling  visitAfterChildren,  the resetting of the key to that of it's parent's, seems inconsistent.
> Last lines in visit(NodeVisitor visitor, ConfigurationKey key) 
>             if (key != null)
>             {
>                 key.setLength(length);
>             }
>             visitor.visitAfterChildren(this, key);

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Updated: (CONFIGURATION-396) In HierarchicalConfiguration$Node visits the ConfigurationKey points to the parent path in visitAfterChildren call

Posted by "Vasanth Amana (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/CONFIGURATION-396?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Vasanth Amana updated CONFIGURATION-396:
----------------------------------------

    Description: 
When visiting a child the key is aggregated to have the child node name, and a call to visitBeforeChildren and grandChildren's visits are made.

However, before calling  visitAfterChildren,  the resetting of the key to that of it's parent's, seems inconsistent.

Last lines in visit(NodeVisitor visitor, ConfigurationKey key) 

            if (key != null)
            {
                key.setLength(length);
            }
            visitor.visitAfterChildren(this, key);


  was:
When visiting a child the key is aggregated to have the child node name, and a call to visitBeforeChildren and grandChildren's visits are made.

However, before calling  visitAfterChildren,  the resetting of the key to that of it's parent's, seems inconsistent.

public void visit(NodeVisitor visitor, ConfigurationKey key)
        {
            int length = 0;
            if (key != null)
            {
                length = key.length();
                if (getName() != null)
                {
                    key
                            .append(StringUtils
                                    .replace(
                                            isAttribute() ? ConfigurationKey
                                                    .constructAttributeKey(getName())
                                                    : getName(),
                                            String
                                                    .valueOf(ConfigurationKey.PROPERTY_DELIMITER),
                                            ConfigurationKey.ESCAPED_DELIMITER));
                }
            }

            visitor.visitBeforeChildren(this, key);

            for (Iterator it = getChildren().iterator(); it.hasNext()
                    && !visitor.terminate();)
            {
                ((Node) it.next()).visit(visitor, key);
            }
            for (Iterator it = getAttributes().iterator(); it.hasNext()
                    && !visitor.terminate();)
            {
                ((Node) it.next()).visit(visitor, key);
            }

            if (key != null)
            {
                key.setLength(length);
            }
            visitor.visitAfterChildren(this, key);
        }
    }


> In HierarchicalConfiguration$Node visits the ConfigurationKey  points to the parent path in visitAfterChildren call
> -------------------------------------------------------------------------------------------------------------------
>
>                 Key: CONFIGURATION-396
>                 URL: https://issues.apache.org/jira/browse/CONFIGURATION-396
>             Project: Commons Configuration
>          Issue Type: Bug
>    Affects Versions: 1.6
>            Reporter: Vasanth Amana
>   Original Estimate: 1h
>  Remaining Estimate: 1h
>
> When visiting a child the key is aggregated to have the child node name, and a call to visitBeforeChildren and grandChildren's visits are made.
> However, before calling  visitAfterChildren,  the resetting of the key to that of it's parent's, seems inconsistent.
> Last lines in visit(NodeVisitor visitor, ConfigurationKey key) 
>             if (key != null)
>             {
>                 key.setLength(length);
>             }
>             visitor.visitAfterChildren(this, key);

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.