Commons JXPath
  1. Commons JXPath
  2. JXPATH-29

null pointer exception in org.apache.commons.jxpath.ri.model.dom.DOMNodePointer when setting a value

    Details

    • Type: Bug Bug
    • Status: Resolved
    • Priority: Critical Critical
    • Resolution: Fixed
    • Affects Version/s: Nightly Builds
    • Fix Version/s: None
    • Labels:
      None
    • Environment:

      Operating System: All
      Platform: All

      Description

      bug in org.apache.commons.jxpath.ri.model.dom.DOMNodePointer

      The problem is when you try and set the value of a DOM node that has more
      than 1 child text node. the clearing of the nodes is ctashing:

      line 366:
      int count = children.getLength();
      for (int i = 0; i < count; i++){
      Node child = children.item;
      if (child.getNodeType() == Node.TEXT_NODE ||
      child.getNodeType() == Node.CDATA_SECTION_NODE)

      { node.removeChild(child); }
      }
      when a node is deleted it is removed from the children list.

      fix:
      int count = children.getLength();
      int nPos=0;
      for (int i = 0; i < count; i++){
      Node child = children.item(nPos);
      if (child.getNodeType() == Node.TEXT_NODE ||
      child.getNodeType() == Node.CDATA_SECTION_NODE){ node.removeChild(child); }

      else

      { nPos++;//only increment position if we are not deleting it }

      }

      This is in both stable and nightly builds

        Activity

        Henri Yandell made changes -
        Affects Version/s Nightly Builds [ 12311823 ]
        Henri Yandell made changes -
        Affects Version/s Nightly Builds [ 12311648 ]
        Component/s JXPath [ 12311120 ]
        Key COM-147 JXPATH-29
        Assignee Jakarta Commons Developers Mailing List [ commons-dev@jakarta.apache.org ]
        Project Commons [ 12310458 ] Commons JXPath [ 12310480 ]
        Henri Yandell made changes -
        Field Original Value New Value
        issue.field.bugzillaimportkey 11951 12340298
        Hide
        Dmitri Plotnikov added a comment -

        Fixed basically as suggested

        Show
        Dmitri Plotnikov added a comment - Fixed basically as suggested
        Mark Pentland created issue -

          People

          • Assignee:
            Unassigned
            Reporter:
            Mark Pentland
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development