CAMEL-24376: Allow boolean-zen operands in Simple logical expressions - #25450
Conversation
Logical AND/OR parsing rejected standalone Simple function tokens used as implicit boolean predicates (boolean zen). Accept SimpleFunctionStart as a valid logical operand and wrap boolean-zen csimple codegen with matchesValue() for valid Java boolean expressions. Co-authored-by: Cursor <cursoragent@cursor.com>
|
Branch rebased on latest upstream/main (cd29991). Bugbot findings addressed: narrowed allowlist to SimpleFunctionStart only; csimple codegen wraps boolean-zen operands with matchesValue(). Branch renamed from AI-generated comment on behalf of atiaomar1978-hub |
|
🌟 Thank you for your contribution to the Apache Camel project! 🌟 🐫 Apache Camel Committers, please review the following items:
|
davsclaus
left a comment
There was a problem hiding this comment.
Looks good — well-scoped fix for boolean-zen shorthand in logical expressions.
What's good:
SimpleFunctionStartis correctly accepted as a valid logical operand via the newisValidPredicateOperand()helper, eliminating the duplicated instanceof check- Runtime path works out of the box:
ExpressionToPredicateAdapter.toPredicate()already delegates toObjectHelper.evaluateValuePredicate()for boolean-zen truthiness - Codegen path (csimple):
matchesValue(exchange, ...)delegates to the sameevaluateValuePredicate()— consistent with runtime semantics - Comprehensive tests: 5 new scenarios covering boolean-zen on left, right, and both sides of
&&/||, false-case, and standalone regression, plus a csimple parser test - Existing tests migrated to AssertJ and package-private — follows project conventions
Minor observations (non-blocking):
- The Javadoc on
isValidPredicateOperand()could be trimmed to a single line, but the boolean-zen context is useful - No unit tests for csimple runtime execution of boolean-zen logical expressions — understandable given csimple is deprecated
This review does not replace specialized review tools (CodeRabbit, Sourcery) or static analysis (SonarCloud).
This review was generated by an AI agent and may contain inaccuracies. Please verify all suggestions before applying.
|
🧪 CI tested the following changed modules:
🔬 Scalpel shadow comparison — Scalpel: 477 tested, 29 compile-only — current: 477 all testedMaveniverse Scalpel detected 506 affected modules (current approach: 477).
|
Description
Fixes https://issues.apache.org/jira/browse/CAMEL-24376
Simple language boolean-zen shorthand (standalone
${header.foo}/${exchangeProperty.foo}as implicit boolean predicates) fails when combined with logical operators||/&&.Example that previously threw
SimpleIllegalSyntaxException:Workaround was to write
${exchangeProperty.forceNewSessionToken} == trueon the RHS.Root cause:
LogicalExpression.acceptLeftNode()/acceptRightNode()only acceptedBinaryExpressionandLogicalExpression, rejectingSimpleFunctionStartused by boolean zen.Fix:
SimpleFunctionStartas a valid logical operand (alongside existing binary/logical nodes)matchesValue(exchange, …)so generated Java uses valid boolean expressionsTests:
SimplePredicateParserLogicalTestwith CAMEL-24376 scenariosCSimplePredicateParserTest.testParseBooleanZenLogicalOrTarget
mainbranch)Tracking
Apache Camel coding standards and style
mvn clean install -DskipTestslocally from root folder and I have committed all auto-generated changes.AI-assisted contributions
Co-authored-bytrailers) and the PR description identifies the AI tool used.AI-generated PR description on behalf of atiaomar1978-hub (Cursor Cloud Agent)