<font color='black' size='2' face='arial'><font color="black" face="arial" size="2">
<div> <font color="black" face="arial" size="2">
<div><font face="Arial, Helvetica, sans-serif">Hi All,<br>
<br>
We have an issue in rule when migrating drools from 3.0 to 5.1 with "eval". To demo this error, I use the following code:<br>
<br>
public class Info {<br>
public String getItem(int i) {<br>
return "item is " + i;<br>
}<br>
}<br>
</font>
</div>
<div> <br>
In Drools 3.0, the following rule is fine:<br>
rule "test eval"<br>
salience 1 <br>
when <br>
info : Info()<br>
eval(into.getItem(0) != null)<br>
then<br>
System.out.println("test eval");<br>
end<br>
<br>
But when using drools 5.1, it shows error "info can not be resolved". I
found a way to resolve this issue but don't know this is the best
practice.<br>
<br>
declare Item<br>
name : String<br>
end<br>
<br>
<font><font color="black" face="arial" size="2">rule "insert item before eval"<br>
salience 0 <br>
when <br>
info : Info()<br>
then<br>
Item item = new Item();<br>
item.setName(info.getItem(0));<br>
insert( item );<br>
end</font></font><br>
<br>
<font><font color="black" face="arial" size="2">rule "test eval"<br>
salience 1 <br>
when <br>
item : Item(n : name)<br>
eval( n != null)<br>
then<br>
System.out.println("test eval");<br>
end</font></font><br>
<br>
BTW, using "declare" in rule may cause memory leaking? We are seeing heap size growing after migrated to 5.1.<br>
<br>
Thanks,<br>
<br>
Liqun</div>
</font>
</div>
<div> <br>
</div>
<div style="clear: both;"></div>
</font></font>