I just fixed this bug on the master and backported it on the 5.5.x branch.<br>Wolfgang, thanks again for your help.<br><br>Mario<br><br><div class="gmail_quote">On Sun, Jan 20, 2013 at 9:23 AM, Wolfgang Laun <span dir="ltr"><<a href="mailto:wolfgang.laun@gmail.com" target="_blank">wolfgang.laun@gmail.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Below is another couple of test cases, showing that the problem is not due<br>
a getter that isn't called get* - it's a more general problem. As far as I<br>
can tell this rule pattern, expecting to fire in ascending order of<br>
Fact.prop, is broken in 5.5.0:<br>
<br>
rule "Rule xx"<br>
when<br>
$fact: Fact( $prop: prop )<br>
not Fact(prop < $prop)<br>
then<br>
System.out.println("Fact.prop: " + $prop);<br>
retract($fact);<br>
end<br>
<br>
// Test case using String<br>
<div class="im"><br>
rule init<br>
salience 9999<br>
when<br>
then<br>
</div> insert( "AAA" );<br>
insert( "DDD" );<br>
insert( "EEE" );<br>
insert( "CCC" );<br>
insert( "BBB" );<br>
end<br>
<br>
rule "Rule 05"<br>
when<br>
$s : String()<br>
not String( this < $s)<br>
then<br>
System.out.println("String found with value: " + $s );<br>
retract($s);<br>
end<br>
<br>
// Test case using declared type<br>
declare Fact<br>
prop : long<br>
end<br>
<br>
rule init<br>
salience 999<br>
when<br>
then<br>
insert( new Fact( 1 ) );<br>
insert( new Fact( 5 ) );<br>
insert( new Fact( 6 ) );<br>
insert( new Fact( 4 ) );<br>
insert( new Fact( 2 ) );<br>
end<br>
<br>
rule "Rule 06"<br>
salience 100<br>
when<br>
$fact : Fact( $prop: prop )<br>
not Fact( prop < $prop )<br>
then<br>
System.out.println("Fact.prop: " + $prop);<br>
retract($fact);<br>
end<br>
<div class="HOEnZb"><div class="h5"><br>
On 20/01/2013, Wolfgang Laun <<a href="mailto:wolfgang.laun@gmail.com">wolfgang.laun@gmail.com</a>> wrote:<br>
> [Sorry - the previous email "escaped" before I was complete.]<br>
><br>
> This is a self-contained DRL demonstrating the erroneous handling of<br>
> a condition involving Integer.intValue (same: Number.intValue), not<br>
> and retract, which is meant to sort the integers. This fails with 5.5.0,<br>
> but works correctly with 5.4.0 and previous versions.<br>
><br>
> rule init<br>
> salience 9999<br>
> when<br>
> then<br>
> insert( Integer.valueOf( 10 ) );<br>
> insert( Integer.valueOf( 50 ) );<br>
> insert( Integer.valueOf( 60 ) );<br>
> insert( Integer.valueOf( 40 ) );<br>
> insert( Integer.valueOf( 20 ) );<br>
> end<br>
><br>
> rule "Rule 04"<br>
> when<br>
> $number : Integer( $i: intValue )<br>
> not Integer(intValue < $i)<br>
> then<br>
> System.out.println("Number found with value: " + $number.intValue());<br>
> retract($number);<br>
> end<br>
><br>
>><br>
>> On 17/01/2013, Wolfgang Laun <<a href="mailto:wolfgang.laun@gmail.com">wolfgang.laun@gmail.com</a>> wrote:<br>
>>> This BAD bug was introduced on the way from 5.4.0 to 5.5.0 (and seems<br>
>>> to have sneaked into 6.0.0 as well).<br>
>>><br>
>>> Only 5.4.0 and predecessors work as expected.<br>
>>><br>
>>> Damage control? How far can 5.5.0 be trusted?<br>
>>><br>
>>><br>
>>> On 17/01/2013, John Smith <<a href="mailto:ffirstt.llastt@gmail.com">ffirstt.llastt@gmail.com</a>> wrote:<br>
>>>> I am new to Drools and am trying to get the sample program to work.<br>
>>>> This<br>
>>>> sample is given in the drools documentation<br>
>>>> <a href="http://docs.jboss.org/drools/release/5.5.0.Final/drools-expert-docs/html_single/index.html#d0e9542" target="_blank">http://docs.jboss.org/drools/release/5.5.0.Final/drools-expert-docs/html_single/index.html#d0e9542</a>.<br>
>>>> This drool rule is expected to sort integers. I just changed the<br>
>>>> numbers<br>
>>>> from what are given in the sample and they do not get sorted as<br>
>>>> expected.<br>
>>>> Tried using drools version 5.5.0, 5.5.1 and the master 6.0.0, but got<br>
>>>> the<br>
>>>> same wrong results.<br>
>>>><br>
>>>> Following is the main code:<br>
>>>> package com.sample;<br>
>>>><br>
>>>> public class Example2 {<br>
>>>> public static void main(String[] args) throws Exception {<br>
>>>> Number[] numbers = new Number[] { wrap(5), wrap(6), wrap(4),<br>
>>>> wrap(1), wrap(2) };<br>
>>>> new RuleRunner().runRules(new String[] { "Example3.drl" },<br>
>>>> numbers);<br>
>>>> }<br>
>>>><br>
>>>> private static Integer wrap(int i) {<br>
>>>> return new Integer(i);<br>
>>>> }<br>
>>>> }<br>
>>>><br>
>>>> The RuleRunner class is the same as given in the example and I do not<br>
>>>> think<br>
>>>> I should give that here, since it will clutter the question. It simply<br>
>>>> creates the KnowledgeBase, stateful session, inserts the facts as given<br>
>>>> in<br>
>>>> the 'numbers' array above and then calls fireAllRules method on the<br>
>>>> session.<br>
>>>><br>
>>>> The rule file (Example3.drl) is:<br>
>>>><br>
>>>><br>
>>>> rule "Rule 04"<br>
>>>> dialect "mvel"<br>
>>>> when<br>
>>>> $number : Number()<br>
>>>> not Number(intValue < $number.intValue)<br>
>>>> then<br>
>>>> System.out.println("Number found with value: " +<br>
>>>> $number.intValue());<br>
>>>> retract($number);<br>
>>>> end<br>
>>>><br>
>>>><br>
>>>> The output I get is as follows:<br>
>>>> Loading file: Example3.drl<br>
>>>> Inserting fact: 5<br>
>>>> Inserting fact: 6<br>
>>>> Inserting fact: 4<br>
>>>> Inserting fact: 1<br>
>>>> Inserting fact: 2<br>
>>>> Number found with value: 1<br>
>>>> Number found with value: 4<br>
>>>> Number found with value: 2<br>
>>>> Number found with value: 5<br>
>>>> Number found with value: 6<br>
>>>><br>
>>>> Not the correct expected ascending sorted order.<br>
>>>><br>
>>>> What might I be doing wrong? I cannot imagine that the drools rule<br>
>>>> engine<br>
>>>> would be broken at this basic level.<br>
>>>><br>
>>>><br>
>>>><br>
>>>> --<br>
>>>> View this message in context:<br>
>>>> <a href="http://drools.46999.n3.nabble.com/Drools-Expert-does-not-sort-integers-correctly-tp4021606.html" target="_blank">http://drools.46999.n3.nabble.com/Drools-Expert-does-not-sort-integers-correctly-tp4021606.html</a><br>
>>>> Sent from the Drools: User forum mailing list archive at Nabble.com.<br>
>>>> _______________________________________________<br>
>>>> rules-users mailing list<br>
>>>> <a href="mailto:rules-users@lists.jboss.org">rules-users@lists.jboss.org</a><br>
>>>> <a href="https://lists.jboss.org/mailman/listinfo/rules-users" target="_blank">https://lists.jboss.org/mailman/listinfo/rules-users</a><br>
>>>><br>
>>><br>
>><br>
><br>
_______________________________________________<br>
rules-dev mailing list<br>
<a href="mailto:rules-dev@lists.jboss.org">rules-dev@lists.jboss.org</a><br>
<a href="https://lists.jboss.org/mailman/listinfo/rules-dev" target="_blank">https://lists.jboss.org/mailman/listinfo/rules-dev</a><br>
</div></div></blockquote></div><br>