Uploaded image for project: 'Commons JXPath'
  1. Commons JXPath
  2. JXPATH-29

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

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Resolved
    • Critical
    • Resolution: Fixed
    • Nightly Builds
    • None
    • None
    • Operating System: All
      Platform: All

    • 11951

    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

      Attachments

        Activity

          People

            Unassigned Unassigned
            mark@golden-orb.com Mark Pentland
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: