davsclaus opened a new pull request, #26767:
URL: https://github.com/apache/camel/pull/26767
Includes #26764 (CAMEL-24920), whose wrapping this shares.
```
${body != null && body.size() > 0}
```
was refused with *Operators go outside the function*. It is what a model
writes, and what a person writes who last wrote JSP, because the braces hold a
full expression in **Jakarta EL** (`${user != null && !user.list.isEmpty()}`),
Groovy GStrings, JavaScript template literals and Thymeleaf. Simple looks like
those and was not, so the wrong guess was the natural one.
The braces now answer the predicate when they hold one:
```
${body != null && body.size() > 0} -> true
${header.n > 0} -> true
${body contains 'ell'} -> true
Over three: ${header.n > 3} -> Over three: true
```
The form with the operators outside means the same and is unchanged, and the
ternary keeps working as before. Inside the braces the answer is a value, so a
template can hold it — which previously needed a ternary.
**What keeps it safe.** An operator counts only when whitespace surrounds
it, outside quotes, and only when the text is not a colon-prefixed function. So
`${header.Content-Length}` is still a name and `${date:now:yyyy-MM-dd}` still a
pattern.
**Measured, not argued.** I extracted every `${...}` in a Camel context from
`camel`, `camel-kamelets`, `camel-examples` and `camel-jbang-examples` —
**3,425 uses, 804 unique** — and parsed all of them on main and on this branch,
comparing what each one became:
```
804 expressions, 0 differences
```
The analysis behind the change, including why a better error message does
not fix it (56 refusals across four benchmark series, and only 17 of 52
follow-up attempts dropped the mistake), is attached to CAMEL-24921.
Also verified from the other end: `PredicateInBracesValidatorTest` in
camel-jbang-core checks that a route using this form passes `SourceValidator`,
so the tools that write files accept what the runtime accepts.
Tests: `SimplePredicateInBracesTest` (the model's shape, single comparisons,
both forms agreeing, template interpolation, names that are not arithmetic, the
ternary still winning), the two hint tests in `SimpleSyntaxHintsTest` updated
to the new behaviour with a malformed predicate still refused. `*Simple*Test`
624 green, full reactor build green. Documented in the operators page and the
4.23 upgrade guide.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
https://claude.ai/code/session_01Bp3538HRBPMQkb5ta9xRaj
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]