Uploaded image for project: 'Jackrabbit Content Repository'
  1. Jackrabbit Content Repository
  2. JCR-3401

Wrong results when querying with a DescendantSelfAxisQuery

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 2.3.7, 2.4.2, 2.5
    • 2.4.3, 2.5.2
    • jackrabbit-core, query
    • None

    Description

      It seems to be caused by the DescendantSelfAxisScorer in the method advance(int target) :

              public int advance(int target) throws IOException {
                  if (currentDoc == NO_MORE_DOCS) {
                      return currentDoc;
                  }
      
                  // optimize in the case of an advance to finish.
                  // see https://issues.apache.org/jira/browse/JCR-3082
                  if (target == NO_MORE_DOCS) {
                      subScorer.advance(target);
                      currentDoc = NO_MORE_DOCS;
                      return currentDoc;
                  }
      
                  currentDoc = subScorer.nextDoc();
                  if (currentDoc == NO_MORE_DOCS) {
                      return NO_MORE_DOCS;
                  } else {
                      collectContextHits();
                      return isValid(currentDoc) ? currentDoc : nextDoc();
                  }
              }
      

      It seems to me that we should have:

      currentDoc = subScorer.advance(target) 
      

      instead of:

      currentDoc = subScorer.nextDoc();
      

      I could provide a patch but I don't know if this is necessary for a single line of code.
      Moreover, I don't know if my fix is ok, as I'm not sure to fully understand the whole picture.

      Attachments

        1. DescendantSelfAxisQuery.java.patch
          1 kB
          Cédric Damioli
        2. SimpleDescendantSelfAxisTest.java
          1.0 kB
          Cédric Damioli

        Activity

          People

            stillalex Alex Deparvu
            cdamioli Cédric Damioli
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: