[jboss-jira] [JBoss JIRA] Updated: (JBRULES-614) logically asserted facts do not get retracted properly

Edson Tirelli (JIRA) jira-events at jboss.com
Mon Jan 22 18:44:53 EST 2007


     [ http://jira.jboss.com/jira/browse/JBRULES-614?page=all ]

Edson Tirelli updated JBRULES-614:
----------------------------------

    Fix Version/s: 3.0.6

> logically asserted facts do not get retracted properly
> ------------------------------------------------------
>
>                 Key: JBRULES-614
>                 URL: http://jira.jboss.com/jira/browse/JBRULES-614
>             Project: JBoss Rules
>          Issue Type: Bug
>      Security Level: Public(Everyone can see) 
>    Affects Versions: 3.0.5
>            Reporter: Philipp Rechberger
>         Assigned To: Edson Tirelli
>             Fix For: 3.0.6
>
>
> 1) Setup the following rules:
> rule "#1: value out of range (verification)"
> 	when
> 		val : Value( value > 100 )
> 	then
> 		System.out.println("found invalid value: " + val.getValue()); 
> 		
> 		assertLogical(new Message("value out of range"));
> end
> rule "#2: value out of range (print out)"
> 	when
> 		Message( message == "value out of range" )
> 	then
> 		System.out.println("value out of range"); 
> end
> 2) Assert a Value fact that triggers rule #1 (note that the Value Bean provides Property Change Support for its "value" attribute):
>             // assert fact - invalid value
>             Value value = new Value(101);
>             FactHandle handle = workingMemory.assertObject(value);
>             workingMemory.fireAllRules();
> => Output looks like this:
> found invalid value: 101
> value out of range
> --- working memory dump ---
> class com.sample.Value: value = 101
> class com.sample.Message: value out of range
> 3) Now modify the Value fact:
>             // modify fact - invalid value
>             value.setValue(102);
>             workingMemory.modifyObject(handle, value);
>             workingMemory.fireAllRules();
> => Output looks like this:
> found invalid value: 102
> value out of range
> --- working memory dump ---
> class com.sample.Value: value = 102
> class com.sample.Message: value out of range
> class com.sample.Message: value out of range
> => A bit strange here: we have two Message objects - but this could be ok if both objects get retracted after modifying Value fact's value, so that it does not support the truth for rule #1... let's test
> 4) Modify the value fact again:
>             // modify fact - valid value
>             value.setValue(100);
>             workingMemory.modifyObject(handle, value);
>             workingMemory.fireAllRules();
> => Output looks like this:
> <none>
> --- working memory dump ---
> class com.sample.Value: value = 100
> class com.sample.Message: value out of range
> Conclusion: There is still a Message fact in the working memory that was asserted logically (by rule) due to the fact Value ( value > 100 ), which does not exist any more! The (second) Message fact must be retracted too OR logically asserted facts must be asserted only once (even if the according rule is triggered multiple times). Otherwise the statement in the documentation is incorrect (chapter 3.5.2): "assertLogical(new Something());" is similar to assert, but the object will be automatically retracted when there are no more facts to support the truth of the currently firing rule".

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: http://jira.jboss.com/jira/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

        



More information about the jboss-jira mailing list