[
https://issues.redhat.com/browse/DROOLS-6019?page=com.atlassian.jira.plug...
]
Mario Fusco commented on DROOLS-6019:
-------------------------------------
I reproduced the problem with the following unit test
{code:java}
@Test
public void testLambdaInConsequence() {
// DROOLS-6019
String str =
"import " + List.class.getCanonicalName() + ";\n" +
"import " + Person.class.getCanonicalName() + ";\n" +
"rule R1 when\n" +
" $l: List()\n" +
" $p: Person()\n" +
"then\n" +
" $l.forEach( x -> { System.out.println(x); } );\n" +
" $p.setName(\"Mario\");\n" +
"end\n";
KieSession ksession = getKieSession( str );
Person person = new Person( "Mark", 45 );
ksession.insert( person );
ksession.insert( new ArrayList<>() );
assertEquals(1, ksession.fireAllRules());
assertEquals("Mario", person.getName());
} {code}
Note that this happens only if you have a lambda with an inner block, in this case if you
rewrite it as
{code:java}
$l.forEach( x -> System.out.println(x) );{code}
then it works.
We planned to replace the old antlr3 based Java parser that we use in drools-compiler with
the newer parser that we're already using to generate the executable model as
explained here
https://issues.redhat.com/browse/DROOLS-4397 and this rework will also
implicitly solve this problem. I already checked that the drl above works with the
executable model.
Using Java 8 stream lambda in RHS leads to compilation error
-------------------------------------------------------------
Key: DROOLS-6019
URL:
https://issues.redhat.com/browse/DROOLS-6019
Project: Drools
Issue Type: Bug
Affects Versions: 7.32.0.Final, 7.49.0.Final
Reporter: Christoph Mayr-Dorn
Assignee: Mario Fusco
Priority: Major
Attachments: DroolsLambdaDemo.zip
When using a lambda expression in the left hand side, any variable that is first used
after the lambda expression is not added as a method parameter of (defaultConsequence),
and leads to error of the following type:
Exception in thread "main" java.lang.RuntimeException: Rule Base Build
Errors:Exception in thread "main" java.lang.RuntimeException: Rule Base Build
Errors:Error Messages:Message [id=1, kieBase=defaultKieBase, level=ERROR,
path=rules/demo.drl, line=9, column=0 text=Rule Compilation error $other cannot be
resolved]---Warning Messages:---Info Messages:
at demo.StartDemo.createKsessionFromFiles(StartDemo.java:51) at
demo.StartDemo.main(StartDemo.java:20)
--
This message was sent by Atlassian Jira
(v8.13.1#813001)