Null value dereference [LUCENE-6602]
- Dominant language
- Java
- Stars
- 3.6k
- Forks
- 1.4k
- Avg merge
- 2d 11h
- Merged PRs (30d)
- 88
Description
In the file `BoostQueryNode.java`, `getChild` could be null and it is being dereferenced in the function `toString()`.
```Java
public QueryNode getChild() {
List children = getChildren();
if (children == null || children.size() == 0) {
return null;
}
return children.get(0);
}
```
```Java
public String toString() {
return "" + "\n"
+ getChild().toString() + "\n";
}
```
Should we not check if getChild is valid?
```Java
String s = (getChild() != null) ? getChild().toString() : "null";
return "" + "\n"
+ s + "\n";
```
---
Migrated from [LUCENE-6602](https://issues.apache.org/jira/browse/LUCENE-6602) by Rishabh Patel, updated May 09 2016
Contributor guide
Research direction
Open BoostQueryNode.java and inspect getChild() alongside toString(), focusing on the null-child path described in the issue. Verify the behavior for a node with no child, then confirm that toString() no longer dereferences null and produces the intended output.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java
- Domain
- search
- Issue type
- Bug
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 38/100