[ 
https://issues.apache.org/jira/browse/CAMEL-24686?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Work on CAMEL-24686 started by Federico Mariani.
------------------------------------------------
> camel-joor - headerAs/exchangePropertyAs default-value patterns match across 
> two calls on the same line
> -------------------------------------------------------------------------------------------------------
>
>                 Key: CAMEL-24686
>                 URL: https://issues.apache.org/jira/browse/CAMEL-24686
>             Project: Camel
>          Issue Type: Bug
>          Components: camel-joor
>    Affects Versions: 4.22.0
>            Reporter: Federico Mariani
>            Assignee: Federico Mariani
>            Priority: Major
>
> {{JoorCompiler}}'s {{HEADER_AS_DEFAULT_VALUE_PATTERN}} (and {{_NO_CLASS}}, 
> and the {{EXCHANGE_PROPERTY_AS_DEFAULT_VALUE_PATTERN}} pair) use a greedy 
> {{(.+)}} for the default value, so a script with two calls on one line is 
> rewritten across both:
> {code}
> 'order-' + headerAs('amount', Integer) + '-' + headerAs('vip', Boolean)
> {code}
> generates {{headerAs(message, "amount",  Integer) + "-" + headerAs(message, 
> "vip", Boolean.class)}} and fails to compile with {{cannot find symbol: 
> variable Integer}}. The {{.class}} dot in the patterns is also unescaped and 
> the quote class {{['|"]}} accepts a literal {{|}}. Workaround: write 
> {{Integer.class}}.
> Proposed fix (implemented, tested): the default value is matched as 
> {{((?:[^()]|\([^()]*\))+?)}} (no parentheses except one balanced level, so it 
> can never reach the next call; a plain lazy {{(.+?)}} still spans mixed two- 
> and three-argument calls), the dot escaped, the quote class {{['"]}}. Three 
> new tests (two two-argument calls, two three-argument calls including a mixed 
> form and a default containing parentheses, and the {{exchangePropertyAs}} 
> variants) fail on the old patterns and pass with the fix.
> Related: CAMEL-15741 (default-value functions added).
> ----
> _Found during a benchmark review of camel-groovy and the other scripting 
> languages (camel-performance-tests branch camel-groovy-perf, 
> tests/camel-jmh/groovy-results, JMH 1.37, JDK 21, one M1 Pro laptop). A 
> candidate fix with tests exists on the local apache/camel branch 
> camel-perf-all-fixes; a PR follows._
> _Claude Code on behalf of Croway_



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

Reply via email to