Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Align instanceof check with type cast #13039

Merged
merged 2 commits into from
Jan 30, 2024
Merged

Conversation

sabi0
Copy link
Contributor

@sabi0 sabi0 commented Jan 28, 2024

No description provided.

@@ -107,10 +105,9 @@ public QueryNode process(QueryNode queryTree) throws QueryNodeException {
@Override
protected QueryNode postProcessNode(QueryNode node) throws QueryNodeException {

if (node instanceof TextableQueryNode
if (node instanceof FieldQueryNode
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

'node' is cast below to FieldQueryNode. But the condition here was checking for a base type TextableQueryNode, excluding some sub-types. If a new TextableQueryNode sub-type was added the code below could run into a CCE.

Having the instanceof FieldQueryNode condition here makes the type cast below safe. And also eliminates the need to exclude the RegexpQueryNode as it does not subclass FieldQueryNode.

@uschindler uschindler self-assigned this Jan 30, 2024
@uschindler uschindler added this to the 9.10.0 milestone Jan 30, 2024
@uschindler uschindler merged commit 13ea880 into apache:main Jan 30, 2024
4 checks passed
@uschindler
Copy link
Contributor

I added the changes entry to the existing one for you.

asfgit pushed a commit that referenced this pull request Jan 30, 2024
@sabi0
Copy link
Contributor Author

sabi0 commented Jan 30, 2024

Thank you. I will make sure the new PRs have them out of the box.

@sabi0 sabi0 deleted the instanceof_cast branch January 30, 2024 10:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants