Tokenizer input state detection should reset state before throwing [LUCENE-6979]
- Dominant language
- Java
- Stars
- 3.6k
- Forks
- 1.4k
- Avg merge
- 2d 11h
- Merged PRs (30d)
- 88
Description
The Tokenizer will helpfully let you know that you're using it wrong in certain cases, like if you forget to close it. However it does this in a way that happens lazily (after the fact) but worse it keeps the state of the Tokenizer in a cranky state (i.e. if you try to use it again, you'll get an exception again). What makes this issue insidious is that Tokenizers are re-used via a ReuseStrategy in a ThreadLocal. So once you hit this bug, you're thread is, in a word, "poisoned". And what makes the stack trace a real head-scratcher is that it is not of the original "guilty" party that didn't close; it's likely some other caller, perhaps an indexing thread who isn't going to misuse the TokenStream, or at least hasn't yet. The error message could make that clearer.
---
Migrated from [LUCENE-6979](https://issues.apache.org/jira/browse/LUCENE-6979) by David Smiley (@dsmiley), 1 vote
Contributor guide
Research direction
Start by tracing the Tokenizer input-state checks and how Tokenizers are reused through ReuseStrategy in a ThreadLocal. Confirm where the lazy validation throws and how the tokenizer state remains poisoned. Done means invalid use resets the state before throwing and the error message makes the original misuse clearer.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java
- Domain
- backend, search
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100