[
http://jira.jboss.com/jira/browse/JBRULES-614?page=all ]
Edson Tirelli resolved JBRULES-614.
-----------------------------------
Fix Version/s: 3.1-m2
(was: 3.0.6)
Resolution: Done
Fixed the problem in trunk in revision #9620. Branch 3.0.6 code is completelly different
and will not be fixed unless we receive a backport request.
------------------------------------------------------------------------
r9620 | tirelli | 2007-02-19 18:43:17 -0300 (Mon, 19 Feb 2007) | 1 line
Changed paths:
M /labs/jbossrules/trunk/drools-compiler/src/test/java/org/drools/Alarm.java
M
/labs/jbossrules/trunk/drools-compiler/src/test/java/org/drools/integrationtests/IntegrationCases.java
A
/labs/jbossrules/trunk/drools-compiler/src/test/resources/org/drools/integrationtests/test_logicalAssertions3.drl
M
/labs/jbossrules/trunk/drools-core/src/main/java/org/drools/base/ShadowProxyFactory.java
M
/labs/jbossrules/trunk/drools-core/src/test/java/org/drools/base/ShadowProxyFactoryTest.java
JBRULES-614: fixing equals method generation for shadow proxy, to fix TMS problem
------------------------------------------------------------------------
TMS requires shadow facts to accept equals() calls receiving the proxied class as
parameters. So I changed equals() method generation for shadow proxies from that:
---------------------------------------------------
public class CheeseShadowProxy extends Cheese {
...
public boolean equals( Object o ) {
if( this == o )
return true;
if(( o == null ) || ( ! ( o instanceof CheeseShadowProxy ) ) )
return false;
CheeseShadowProxy other = (CheeseShadowProxy) o;
// code comparing attribute values
...
}
}
----------------------------------------------------
To that:
----------------------------------------------------
public class CheeseShadowProxy extends Cheese {
...
public boolean equals( Object o ) {
if( this == o )
return true;
if(( o == null ) || ( ! ( o instanceof Cheese ) ) )
return false;
Cheese other = (Cheese) o;
// code comparing attribute values
...
}
}
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.1-m2
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