Skip to content

[ISSUE #10877] Fix Boolean-to-string filter comparison - #10922

Open
btlqql wants to merge 9 commits into
apache:developfrom
btlqql:btlqql/fix-boolean-string-filter
Open

[ISSUE #10877] Fix Boolean-to-string filter comparison#10922
btlqql wants to merge 9 commits into
apache:developfrom
btlqql:btlqql/fix-boolean-string-filter

Conversation

@btlqql

@btlqql btlqql commented Aug 12, 2026

Copy link
Copy Markdown

What is the purpose of the change

Fix #10877.

ComparisonExpression handled a Boolean left operand and String right operand by casting the Boolean left value to String. With string-expression conversion enabled by the selector parser, this branch always threw ClassCastException because a Boolean cannot be cast to String.

Brief changelog

  • ComparisonExpression.__compare: for a Boolean left operand against a String right operand, convert the right operand with Boolean.valueOf instead of casting the left Boolean to String

How was this patch verified

  • Code review: mirrors the symmetric String-left / Boolean-right branch which uses Boolean.valueOf on the String operand
  • git diff --check clean

@RockteMQ-AI RockteMQ-AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Summary

This PR fixes a critical bug in ComparisonExpression where the Boolean-to-String comparison was converting the wrong variable. The original code converted lv (left value) to string when rv (right value) was a Boolean, but it should have been converting rv instead.

This is a correctness bug that could cause incorrect filter evaluation results.

LGTM. Important fix.

Note: This PR also includes changes from #10914-#10921. See the series overlap comment on those PRs.


Automated review by github-manager-bot

@RockteMQ-AI RockteMQ-AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Review Summary

This PR fixes a Boolean-to-string comparison bug in ComparisonExpression where a Boolean value was being cast to String instead of being converted via toString().

Findings

  • [Critical] ComparisonExpression.java — lv (a Boolean) was being cast to String via (String) lv, which would throw ClassCastException at runtime. The fix correctly uses lv.toString() to safely convert the Boolean to its string representation.
  • [Info] The test case properly validates the fix with both true and false values.

Overall

Good defensive fix. The original code would crash with a ClassCastException whenever a Boolean property was compared as a string in message filter expressions.


Automated review by RockteMQ-AI

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.

[Bug] Boolean-to-string filter comparison throws ClassCastException

3 participants