[ISSUE #10877] Fix Boolean-to-string filter comparison - #10922
Conversation
…t its bound topic
RockteMQ-AI
left a comment
There was a problem hiding this comment.
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
left a comment
There was a problem hiding this comment.
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(aBoolean) was being cast toStringvia(String) lv, which would throwClassCastExceptionat runtime. The fix correctly useslv.toString()to safely convert the Boolean to its string representation. - [Info] The test case properly validates the fix with both
trueandfalsevalues.
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
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
How was this patch verified
git diff --checkclean