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

NPE in StopFilter caused by StandardAnalyzer(boolean replaceInvalidAcronym) constructor

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Blocker
    • Resolution: Fixed
    • Affects Version/s: 2.3
    • Fix Version/s: 2.3
    • Component/s: modules/analysis
    • Labels:
      None

      Description

      I think that I found a problem with the new code (https://issues.apache.org/jira/browse/LUCENE-1068).
      Usage of the new constructor StandardAnalyzer(boolean replaceInvalidAcronym) causes NPE in
      StopFilter:

      java.lang.NullPointerException
      at org.apache.lucene.analysis.StopFilter.<init>(StopFilter.java:74)
      at org.apache.lucene.analysis.StopFilter.<init>(StopFilter.java:86)
      at
      org.apache.lucene.analysis.standard.StandardAnalyzer.tokenStream(StandardAnalyzer.java:151)
      at
      org.apache.lucene.queryParser.QueryParser.getFieldQuery(QueryParser.java:452)
      at
      org.apache.lucene.queryParser.QueryParser.Term(QueryParser.java:1133)
      at
      org.apache.lucene.queryParser.QueryParser.Clause(QueryParser.java:1020)
      at
      org.apache.lucene.queryParser.QueryParser.Query(QueryParser.java:948)
      at
      org.apache.lucene.queryParser.QueryParser.Clause(QueryParser.java:1024)
      at
      org.apache.lucene.queryParser.QueryParser.Query(QueryParser.java:948)
      at
      org.apache.lucene.queryParser.QueryParser.TopLevelQuery(QueryParser.java:937)
      at
      org.apache.lucene.queryParser.QueryParser.parse(QueryParser.java:147)

      The reason is that new constructor forgets to initialize the stopSet field:
      public StandardAnalyzer(boolean replaceInvalidAcronym)

      { this.replaceInvalidAcronym = replaceInvalidAcronym; }

      I guess this should be changed to something like this:
      public StandardAnalyzer(boolean replaceInvalidAcronym)

      { this(STOP_WORDS); this.replaceInvalidAcronym = replaceInvalidAcronym; }

      The bug is present in RC3. Fix is one line, it'll be great to have it in 2.3
      release.

      1. LUCENE-1140.patch
        3 kB
        Grant Ingersoll

        Issue Links

          Activity

          Hide
          dets Alexei Dets added a comment -

          Yes, patch fixes the issue.

          Show
          dets Alexei Dets added a comment - Yes, patch fixes the issue.
          Hide
          gsingers Grant Ingersoll added a comment -

          Committed on 613282 and 613280 (trunk and branch)

          Show
          gsingers Grant Ingersoll added a comment - Committed on 613282 and 613280 (trunk and branch)
          Hide
          gsingers Grant Ingersoll added a comment - - edited

          Try this one. I will commit to trunk and 2.3 branch shortly. (and I'll fix the CHANGES offset issue to be right, despite what is in the patch.)

          Show
          gsingers Grant Ingersoll added a comment - - edited Try this one. I will commit to trunk and 2.3 branch shortly. (and I'll fix the CHANGES offset issue to be right, despite what is in the patch.)
          Hide
          gsingers Grant Ingersoll added a comment -

          Argh, yep. Stupid me. Didn't create the default Stop Set. I'm on it.

          Show
          gsingers Grant Ingersoll added a comment - Argh, yep. Stupid me. Didn't create the default Stop Set. I'm on it.

            People

            • Assignee:
              gsingers Grant Ingersoll
              Reporter:
              dets Alexei Dets
            • Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:

                Development