lucene-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Michael McCandless (Created) (JIRA)" <>
Subject [jira] [Created] (LUCENE-3766) Remove/deprecate Tokenizer's default ctor
Date Thu, 09 Feb 2012 16:31:59 GMT
Remove/deprecate Tokenizer's default ctor

                 Key: LUCENE-3766
             Project: Lucene - Java
          Issue Type: Improvement
            Reporter: Michael McCandless
             Fix For: 3.6, 4.0

I was working on a new Tokenizer... and I accidentally forgot to call super(input) (and super.reset(input)
from my reset method)... which then meant my correctOffset() calls were silently a no-op;
this is very trappy.

Fortunately the awesome BaseTokenStreamTestCase caught this (I hit failures because the offsets
were not in fact being corrected).

One minimal thing we can do (but it sounds like from Robert there may be reasons why we can't)
is add {{assert input != null}} in Tokenizer.correctOffset:

Index: lucene/core/src/java/org/apache/lucene/analysis/
--- lucene/core/src/java/org/apache/lucene/analysis/	(revision 1242316)
+++ lucene/core/src/java/org/apache/lucene/analysis/	(working copy)
@@ -82,6 +82,7 @@
    * @see CharStream#correctOffset
   protected final int correctOffset(int currentOff) {
+    assert input != null: "subclass failed to call super(Reader) or super.reset(Reader)";
     return (input instanceof CharStream) ? ((CharStream) input).correctOffset(currentOff)
: currentOff;

But best would be to remove the default ctor that leaves input null...

This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators:!default.jspa
For more information on JIRA, see:


To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message