Details

    • Type: Bug Bug
    • Status: Resolved
    • Priority: Blocker Blocker
    • Resolution: Fixed
    • Affects Version/s: 1.0 Final
    • Fix Version/s: None
    • Labels:
      None
    • Environment:

      Operating System: All
      Platform: All

      Description

      I probably noticed a bug, when I use dynamic beans and iteratePointers() and
      then the asPath() method on each pointer.

      Assuming the toplevel (dynamic) bean has 3 attributes att1, att1, att3 and att3
      is a nested bean whit attribute called 'nested'.

      The following works:

      context.getValue("/att3/nested");

      Whereas this throws an exception:

      Iterator it = context.iteratePointers("/att3");
      Pointer ptr = it.next();
      context.getValue(ptr.asPath()+"/nested");

      I provided a testcase.

        Activity

        Hide
        Dmitri Plotnikov added a comment -

        Fixed this problem - it had to do with the resolution of chains of dynamic
        property objects.

        ===================================================================
        RCS file: /home/cvs/jakarta-
        commons/jxpath/src/java/org/apache/commons/jxpath/ri/model/beans/PropertyOwnerPo
        inter.java,v
        retrieving revision 1.4
        diff -r1.4 PropertyOwnerPointer.java
        158,165d157
        < /**
        < * If has an index, returns a pointer to the collection element,
        < * otherwise returns the pointer itself.
        < */
        < public NodePointer getValuePointer()

        { < return NodePointer.newChildNodePointer(this, getName(), getNodeValue ()); < }

        <
        Index: src/java/org/apache/commons/jxpath/ri/axes/PredicateContext.java
        ===================================================================
        RCS file: /home/cvs/jakarta-
        commons/jxpath/src/java/org/apache/commons/jxpath/ri/axes/PredicateContext.java,
        v
        retrieving revision 1.10
        diff -r1.10 PredicateContext.java
        139a140,143
        > if (parent == null)

        { > return false; > }

        > parent = parent.getValuePointer();
        143c147,148
        < dynamicPropertyPointer = ((PropertyOwnerPointer)
        parent).getPropertyPointer();

        > dynamicPropertyPointer =
        > ((PropertyOwnerPointer)parent).getPropertyPointer();
        Index: src/java/org/apache/commons/jxpath/ri/model/NodePointer.java
        ===================================================================
        RCS file: /home/cvs/jakarta-
        commons/jxpath/src/java/org/apache/commons/jxpath/ri/model/NodePointer.java,v
        retrieving revision 1.6
        diff -r1.6 NodePointer.java
        410,412c410,414
        < NodeTest test,
        < boolean reverse,
        < NodePointer startWith) {

        > NodeTest test, boolean reverse, NodePointer startWith) {
        > NodePointer valuePointer = getValuePointer();
        > if (valuePointer != null && valuePointer != this)

        { > return valuePointer.childIterator(test, reverse, startWith); > }

        Index: src/test/org/apache/commons/jxpath/JXPathTestCase.java
        ===================================================================
        RCS file: /home/cvs/jakarta-
        commons/jxpath/src/test/org/apache/commons/jxpath/JXPathTestCase.java,v
        retrieving revision 1.23
        diff -r1.23 JXPathTestCase.java
        288a289,290
        > bean.getMap().put("biz", tm);
        >
        289a292
        > testGetValue(context, "map[@name='biz'][@name='bar']", "zz");
        1203a1207,1214
        > test("map/Key2/name", "Name 6"),
        > testPath("map/Key2/name", "/map[@name='Key2']/name"),
        > test("/.[@name='map']/Key2/name", "Name 6"),
        > testPath("/.[@name='map']/Key2/name", "/map[@name='Key2']/name"),
        > test("/map[@name='Key2'][@name='name']", "Name 6"),
        > testPath("/map[@name='Key2'][@name='name']", "/map
        [@name='Key2']/name"),
        > test("/.[@name='map'][@name='Key2'][@name='name']", "Name 6"),
        > testPath("/.[@name='map'][@name='Key2'][@name='name']", "/map
        [@name='Key2']/name"),

        Show
        Dmitri Plotnikov added a comment - Fixed this problem - it had to do with the resolution of chains of dynamic property objects. =================================================================== RCS file: /home/cvs/jakarta- commons/jxpath/src/java/org/apache/commons/jxpath/ri/model/beans/PropertyOwnerPo inter.java,v retrieving revision 1.4 diff -r1.4 PropertyOwnerPointer.java 158,165d157 < /** < * If has an index, returns a pointer to the collection element, < * otherwise returns the pointer itself. < */ < public NodePointer getValuePointer() { < return NodePointer.newChildNodePointer(this, getName(), getNodeValue ()); < } < Index: src/java/org/apache/commons/jxpath/ri/axes/PredicateContext.java =================================================================== RCS file: /home/cvs/jakarta- commons/jxpath/src/java/org/apache/commons/jxpath/ri/axes/PredicateContext.java, v retrieving revision 1.10 diff -r1.10 PredicateContext.java 139a140,143 > if (parent == null) { > return false; > } > parent = parent.getValuePointer(); 143c147,148 < dynamicPropertyPointer = ((PropertyOwnerPointer) parent).getPropertyPointer(); — > dynamicPropertyPointer = > ((PropertyOwnerPointer)parent).getPropertyPointer(); Index: src/java/org/apache/commons/jxpath/ri/model/NodePointer.java =================================================================== RCS file: /home/cvs/jakarta- commons/jxpath/src/java/org/apache/commons/jxpath/ri/model/NodePointer.java,v retrieving revision 1.6 diff -r1.6 NodePointer.java 410,412c410,414 < NodeTest test, < boolean reverse, < NodePointer startWith) { — > NodeTest test, boolean reverse, NodePointer startWith) { > NodePointer valuePointer = getValuePointer(); > if (valuePointer != null && valuePointer != this) { > return valuePointer.childIterator(test, reverse, startWith); > } Index: src/test/org/apache/commons/jxpath/JXPathTestCase.java =================================================================== RCS file: /home/cvs/jakarta- commons/jxpath/src/test/org/apache/commons/jxpath/JXPathTestCase.java,v retrieving revision 1.23 diff -r1.23 JXPathTestCase.java 288a289,290 > bean.getMap().put("biz", tm); > 289a292 > testGetValue(context, "map [@name='biz'] [@name='bar'] ", "zz"); 1203a1207,1214 > test("map/Key2/name", "Name 6"), > testPath("map/Key2/name", "/map [@name='Key2'] /name"), > test("/. [@name='map'] /Key2/name", "Name 6"), > testPath("/. [@name='map'] /Key2/name", "/map [@name='Key2'] /name"), > test("/map [@name='Key2'] [@name='name'] ", "Name 6"), > testPath("/map [@name='Key2'] [@name='name'] ", "/map [@name='Key2'] /name"), > test("/. [@name='map'] [@name='Key2'] [@name='name'] ", "Name 6"), > testPath("/. [@name='map'] [@name='Key2'] [@name='name'] ", "/map [@name='Key2'] /name"),
        Hide
        Markus Menner added a comment -

        Created an attachment (id=2104)
        Testcase for COM-95

        Show
        Markus Menner added a comment - Created an attachment (id=2104) Testcase for COM-95

          People

          • Assignee:
            Unassigned
            Reporter:
            Markus Menner
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development