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

NullPointerException in ChildContext when document only contains an empty root node

    Details

    • Type: Bug
    • Status: Resolved
    • Priority: Minor
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: 1.4
    • Labels:
      None

      Description

      In ChildContext I get a NullPointerException, the error appears in method prepare()

          iterator = (startFromParentLocation ? parent.getParent() : parent).childIterator(nodeTest,
                      reverse, startFromParentLocation ? parent : null);
      

      should be changed in my opinion to

      final NodePointer actualParent = startFromParentLocation ? parent.getParent() : parent;
              iterator = actualParent==null ? null : actualParent.childIterator(nodeTest,
                      reverse, startFromParentLocation ? parent : null);
      

      The tests triggering the error are testIssue172_CountFollowingSiblingNode and testIssue172_CountPrecedingSiblingNode

        Attachments

          Activity

            People

            • Assignee:
              britter Benedikt Ritter
              Reporter:
              vivodamichele@hotmail.com Michele Vivoda
            • Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: