Uploaded image for project: 'Lucene - Core'
  1. Lucene - Core
  2. LUCENE-1046

Dead code in SpellChecker.java (branch never executes)

    Details

    • Type: Bug
    • Status: Resolved
    • Priority: Minor
    • Resolution: Fixed
    • Affects Version/s: 2.2
    • Fix Version/s: None
    • Component/s: modules/spellchecker
    • Labels:
      None
    • Lucene Fields:
      New, Patch Available

      Description

      SpellChecker contains the following lines of code:

      final int goalFreq = (morePopular && ir != null) ? ir.docFreq(new Term(field, word)) : 0;
      // if the word exists in the real index and we don't care for word frequency, return the word itself
      if (!morePopular && goalFreq > 0) {
      return new String[]

      { word }

      ;
      }

      The branch will never execute: the only way for goalFreq to be greater than zero is if morePopular is true, but if morePopular is true, the expression in the if statement evaluates to false.

        Activity

        Hide
        lucenebugs@danielnaber.de Daniel Naber added a comment -

        Thanks for your report, could you try out this patch?

        Show
        lucenebugs@danielnaber.de Daniel Naber added a comment - Thanks for your report, could you try out this patch?
        Hide
        otis Otis Gospodnetic added a comment -

        Good catch. I'll commit next week.

        Show
        otis Otis Gospodnetic added a comment - Good catch. I'll commit next week.
        Hide
        otis Otis Gospodnetic added a comment -

        Danke schön.

        Committed revision 659019.

        Show
        otis Otis Gospodnetic added a comment - Danke schön. Committed revision 659019.
        Hide
        gsingers Grant Ingersoll added a comment -

        Note, this patch has the effect of changing output from the spell checker. I think the new behavior is correct, just letting people know that they will now get the original word back for this case, where they did not before.

        Show
        gsingers Grant Ingersoll added a comment - Note, this patch has the effect of changing output from the spell checker. I think the new behavior is correct, just letting people know that they will now get the original word back for this case, where they did not before.

          People

          • Assignee:
            otis Otis Gospodnetic
            Reporter:
            joe1111 Joe
          • Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development