[
https://issues.apache.org/jira/browse/CAMEL-23377?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]
Raymond updated CAMEL-23377:
----------------------------
Summary: simple language - Multiline init blocks aren't initialized
properly (was: simple language - Multiline init blocks are initialized
properly)
> simple language - Multiline init blocks aren't initialized properly
> -------------------------------------------------------------------
>
> Key: CAMEL-23377
> URL: https://issues.apache.org/jira/browse/CAMEL-23377
> Project: Camel
> Issue Type: Bug
> Components: camel-core
> Affects Versions: 4.20.0
> Reporter: Raymond
> Assignee: Claus Ibsen
> Priority: Minor
> Fix For: 4.21.0
>
>
> I was following the latest (Next) documentation of Simple expressions:
> [https://camel.apache.org/components/next/languages/simple-language.html#_init_blocks]
> I used the following example:
>
> {code:java}
> $init{
> $greeting := ${upper('Hello $body}'}
> $level := ${header.code > 999 ? 'Gold' : 'Silver'}
> }init$
> {
> "message": "$greeting",
> "status": "$level"
> }
> {code}
> The example still seems from 4.18.x, and has several issues:
> 1. upper --> uppercase
> 2. uppercase function is not properly closed with a )
> 3. No ; after the variable declaration
> After the correction it looks like this:
>
> {code:java}
> $init{
> $greeting := ${uppercase('Hello $body')};
> $level := ${header.code > 999 ? 'Gold' : 'Silver'};
> }init$
> {
> "message": "$greeting",
> "status": "$level"
> } {code}
> However, even when running this code I don't get the expected result.
> *Expected:*
> {code:java}
> {
> "message": "HELLO JOE",
> "status": "Silver"
> }{code}
> *Actual:*
> {code:java}
> {
> "message": "HELLO JOE;
> $level := Silver;
> ",
> "status": "$level"
> } {code}
> So it seems that multiline variable declaration aren't evaluated separately.
> BTW as now ; is used to indicate the end of a line, I would expect that this
> also works (all declaration on one line):
> {code:java}
> $init{$greeting := ${uppercase('Hello $body')}; $level := ${header.code > 999
> ? 'Gold' : 'Silver'};}init$
> {
> "message": "$greeting",
> "status": "$level"
> }{code}
> Maybe good to check this case also.
>
--
This message was sent by Atlassian Jira
(v8.20.10#820010)