ResourceLoaderAware classes should probably throw IllegalStateException if you attempt to use them w/o calling inform() [LUCENE-5926]
- Dominant language
- Java
- Stars
- 3.6k
- Forks
- 1.4k
- Avg merge
- 2d 11h
- Merged PRs (30d)
- 88
Description
Mailing list user reported an NPE from SnowballPorterFilterFactory.create that was ultimately caused by not realizing that they had to call SnowballPorterFilterFactory.inform.
We should consider updating all ResourceLoaderAware classes so that if you attempt to use them w/o calling inform, you consistently get an IllegalStateException w/meaningful error.
ie, in the case of SnowballPorterFilterFactory, something like...
```
`@Override`
public TokenFilter create(TokenStream input) {
if (null == stemClass) {
throw new IllegalStateException("inform(ResourceLoader) method must be called before using this factory");
}
...
```
---
Migrated from [LUCENE-5926](https://issues.apache.org/jira/browse/LUCENE-5926) by Chris M. Hostetter (@hossman)
Contributor guide
Research direction
Start with SnowballPorterFilterFactory.create and its inform(ResourceLoader) method, then identify the other ResourceLoaderAware classes covered by the issue. Review how they behave before inform is called and the existing tests around those factories. Done means each affected class consistently reports a meaningful IllegalStateException instead of an NPE when used prematurely.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java
- Domain
- search
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100