gnodet-bot commented on code in PR #26764:
URL: https://github.com/apache/camel/pull/26764#discussion_r4080928583
##########
core/camel-core-languages/src/main/java/org/apache/camel/language/simple/ast/SimpleFunctionStart.java:
##########
@@ -333,6 +333,49 @@ private String wrapFunctionsInCondition(String
conditionText) {
return conditionText;
}
+ // the condition may be several comparisons joined by a logical
operator, and each of them needs its
+ // functions wrapped, not only the first (CAMEL-24920)
+ StringBuilder answer = new StringBuilder();
+ int from = 0;
+ for (int at = logicalOperator(conditionText, 0); at >= 0; at =
logicalOperator(conditionText, from)) {
+ int end = conditionText.indexOf(' ', at + 1);
+ if (end < 0) {
+ break; // the operator has nothing after it: leave it to the
predicate parser to say so
+ }
Review Comment:
💡 **Dead code / misleading comment.** `end < 0` cannot happen here.
`logicalOperator` only returns when `text.startsWith("&& ", i+1)` or
`text.startsWith("|| ", i+1)` succeeds, which requires a space character at
offset `i+3` — so `indexOf(' ', at+1)` will always find that space at `at+2` at
the latest, guaranteeing `end ≥ 0`. The comment "the operator has nothing after
it" describes a situation the guard cannot reach.
Suggest removing the guard entirely, or replacing it with an `assert false`
if you prefer to document the invariant explicitly:
```suggestion
answer.append(wrapComparison(conditionText.substring(from,
at).trim()));
answer.append(' ').append(conditionText, at, end).append(' ');
```
--
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]