Lucene - Core
  1. Lucene - Core
  2. LUCENE-2839

Visibility of Scorer.score(Collector, int, int) is wrong

    Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: 4.0-ALPHA
    • Component/s: core/search
    • Labels:
      None
    • Lucene Fields:
      New

      Description

      The method for scoring subsets in Scorer has wrong visibility, its marked protected, but protected methods should not be called from other classes. Protected methods are intended for methods that should be overridden by subclasses and are called by (often) final methods of the same class. They should never be called from foreign classes.

      This method is called from another class out-of-scope: BooleanScorer(2) - so it must be public, but it's protected. This does not lead to a compiler error because BS(2) is in same package, but may lead to problems if subclasses from other packages override it. When implementing LUCENE-2838 I hit a trap, as I thought tis method should only be called from the class or Scorer itsself, but in fact its called from outside, leading to bugs, because I had not overridden it. As ConstantScorer did not use it I have overridden it with throw UOE and suddenly BooleanQuery was broken, which made it clear that it's called from outside (which is not the intention of protected methods).

      We cannot fix this in 3.x, as it would break backwards for classes that overwrite this method, but we can fix visibility in trunk.

      1. LUCENE-2839.patch
        6 kB
        Uwe Schindler
      2. LUCENE-2839-3.x.patch
        1.0 kB
        Uwe Schindler

        Issue Links

          Activity

          Hide
          Michael McCandless added a comment -

          +1 let's fix this in 4.0...

          Show
          Michael McCandless added a comment - +1 let's fix this in 4.0...
          Hide
          Uwe Schindler added a comment -

          Here the patch for trunk and 3.x, will commit soon. In 3.x I simply added a note to Scorer's javadocs, that tells the user, that subclasses in user's code should declare the method as public to ease transition to 4.0.

          Show
          Uwe Schindler added a comment - Here the patch for trunk and 3.x, will commit soon. In 3.x I simply added a note to Scorer's javadocs, that tells the user, that subclasses in user's code should declare the method as public to ease transition to 4.0.
          Hide
          Uwe Schindler added a comment -

          Committed trunk revision: 1057010,
          Committed javadoc updates revision: 1057011

          Show
          Uwe Schindler added a comment - Committed trunk revision: 1057010, Committed javadoc updates revision: 1057011

            People

            • Assignee:
              Uwe Schindler
              Reporter:
              Uwe Schindler
            • Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:

                Development