You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Java Version: 21
Spring Boot Version: 3.3.4
KIE Version: 9.44.0.Final
Short summary:
In Drools Template files if there are parameters on a given line that end with a variable name a trailing space must be the last character of the line or during compiling an exception is thrown stating that unclosed @if{} blocks exist in the template file.
Detailed explanation:
Take for example the following drt snippet:
when
$c: Customer($balances : balances != null)
$b_thb: Balance(currency == "@{balanceType}") from $balances
then
Using either DataProviderCompiler or ObjectDataCompiler to compile the above I get the following error:
The exception references the end of the action block. However when I replace the parameter with a concrete example:
when
$c: Customer($balances : balances != null)
$b_thb: Balance(currency == "MAGIC_COIN") from $balances
then
The exception does not come. After a bit of digging around with the debugger I have found that what happens is during compile time KIE wraps every line in if statements that use a parameter, for example the above snippet turns into:
when
$c: Customer($balances : balances != null)
@if{balanceType != null} $b_thb: Balance(currency == "@{balanceType}") from $balances@end{}
then
It then fails to read the @EnD{} statement as the closure of the if at the beginning of the line resulting in an exception. If I then modify the drt file to have a space at the end of this line the compilation is successful. Checking out the ExpressionNode using the debugger we can see the following:
when
$c: Customer($balances : balances != null)
@if{balanceType != null} $b_thb: Balance(currency == "@{balanceType}") from $balances @end{}
then
The text was updated successfully, but these errors were encountered:
Java Version: 21
Spring Boot Version: 3.3.4
KIE Version: 9.44.0.Final
Short summary:
In Drools Template files if there are parameters on a given line that end with a variable name a trailing space must be the last character of the line or during compiling an exception is thrown stating that unclosed @if{} blocks exist in the template file.
Detailed explanation:
Take for example the following drt snippet:
Using either DataProviderCompiler or ObjectDataCompiler to compile the above I get the following error:
Caused by: org.mvel2.CompileException: [Error: unclosed @if{} block. expected @EnD{}]
[Near : {... nceType}");@EnD{} ....}]
The exception references the end of the action block. However when I replace the parameter with a concrete example:
The exception does not come. After a bit of digging around with the debugger I have found that what happens is during compile time KIE wraps every line in if statements that use a parameter, for example the above snippet turns into:
It then fails to read the @EnD{} statement as the closure of the if at the beginning of the line resulting in an exception. If I then modify the drt file to have a space at the end of this line the compilation is successful. Checking out the ExpressionNode using the debugger we can see the following:
The text was updated successfully, but these errors were encountered: