An incomplete fix for the NPE bugs in NearSpansUnordered.java [LUCENE-3783]
- Dominant language
- Java
- Stars
- 3.6k
- Forks
- 1.4k
- Avg merge
- 2d 11h
- Merged PRs (30d)
- 88
Description
The fix revision 698487 was aimed to remove an NPE bug (#2478) on the returned value of "min()" in the method "isPayloadAvailable" of the file "/lucene/java/trunk/src/java/org/apache/lucene/search/spans/NearSpansUnordered.java" , but it is incomplete.
Since the returned value "min()" could be null during the runtime execution, its value should also be null-checked before being dereferenced in other methods.
The buggy code locations the same fix needs to be applied at are as bellows:
Lines 159 , 170 , and 196 of the methods "next()"
Line 216 of the methods "skipTo()"
Line 230 of the methods "doc()"
230 public int doc() { return min().doc(); }
Line 232 of the methods "start()"
232 public int start() { return min().start(); }
Line 315 of the methods "atMatch()"
private boolean atMatch() {
315 return (min().doc() == max.doc())
&& ((max.end() - min().start() - totalLength) <= slop);
}
---
Migrated from [LUCENE-3783](https://issues.apache.org/jira/browse/LUCENE-3783) by Guangtai Liang
Contributor guide
Research direction
Start with lucene/java/trunk/src/java/org/apache/lucene/search/spans/NearSpansUnordered.java and review revision 698487 alongside the listed next(), skipTo(), doc(), start(), and atMatch() locations. Trace when min() can return null, then verify the affected execution paths no longer dereference that value unsafely and run the relevant existing Lucene tests.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java
- Domain
- search
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 45/100