Uploaded image for project: 'ModeShape'
  1. ModeShape
  2. MODE-2126

NodeIterator.hasNext() method returns wrong results

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Done
    • Icon: Major Major
    • 3.7.0.Final, 3.3.x-prod-ip6.0
    • 3.6.0.Final
    • JCR
    • None

      According to API , NodeIterator.hasNext() method should return same result if next() method is not called meanwhile. This is not the case in some situations, when I do some node adding combined with calling clone().

      Fortunately there is a workaround to call session.save() before calling hasNext() method. See attached code.

      example:

              NodeIterator nodeIter = refNode.getNodes("name");
              
              boolean hasnext1 = nodeIter.hasNext();
              boolean hasnext2 = nodeIter.hasNext();
              boolean hasnext3 = nodeIter.hasNext();
      
              System.out.println("CALL1" + hasnext1);
              System.out.println("CALL2" + hasnext2);
              System.out.println("CALL3" + hasnext3);
      

      will output:

      CALL1true
      CALL2false
      CALL3false
      

              hchiorean Horia Chiorean (Inactive)
              mkuzela Martin Kuzela (Inactive)
              Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

                Created:
                Updated:
                Resolved: