Unsafe type cast in flexible parser QueryNodeImpl [LUCENE-7926]
- Dominant language
- Java
- Stars
- 3.6k
- Forks
- 1.4k
- Avg merge
- 2d 11h
- Merged PRs (30d)
- 88
Description
`org.apache.lucene.queryparser.flexible.core.nodes.QueryNodeImplL67` casts the argument to `QueryNodeImpl` although the rest of the code is written against the `QueryNode` interface. This blows up in cases where a non-inheriting implementation is passed (such as using a wrapper/decorator class).
The relevant `setParent` method does not exist on the interface, so the most backwards compatible short term fix would be to wrap the cast in a conditional to ensure it is safe (more significant changes to the hierarchy may make sense but this seems like a fairly stable module).
Patch enclosed...
---
Migrated from [LUCENE-7926](https://issues.apache.org/jira/browse/LUCENE-7926) by Matt Whipple
Attachments: [LUCENE-7926.patch](https://apache.github.io/lucene-jira-archive/attachments/LUCENE-7926/LUCENE-7926.patch)
Contributor guide
Research direction
Start with org.apache.lucene.queryparser.flexible.core.nodes.QueryNodeImpl and inspect the setParent method around the referenced line, then compare its argument handling with the QueryNode interface. Done means non-inheriting QueryNode implementations no longer trigger an unsafe cast while existing parent-setting behavior remains intact.
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
- Mostly clear
- Newbie friendliness
- 35/100