[
http://jira.jboss.com/jira/browse/JBRULES-505?page=all ]
Edson Tirelli resolved JBRULES-505.
-----------------------------------
Fix Version/s: 3.0.5
3.1-m1
Resolution: Done
Assignee: Edson Tirelli (was: Mark Proctor)
ReturnValueConstraint had a problem in the equals method, causing the network to be
wrongly buit in some specific cases.
Fixed in 3.0.x in revision #7522:
------------------------------------------
Sending
drools-compiler/src/test/java/org/drools/integrationtests/IntegrationCases.java
Adding
drools-compiler/src/test/resources/org/drools/integrationtests/test_ReturnValueAndGlobal.drl
Sending drools-core/src/main/java/org/drools/rule/ReturnValueConstraint.java
Transmitting file data ...
Committed revision 7522.
------------------------------------------
Trunk did not had the problem due to code refactoring, but added test case to avoid
regression in revision #7525:
------------------------------------------
Sending
drools-compiler/src/test/java/org/drools/integrationtests/IntegrationCases.java
Adding
drools-compiler/src/test/resources/org/drools/integrationtests/test_ReturnValueAndGlobal.drl
Transmitting file data ..
Committed revision 7525.
------------------------------------------
Matt, thanks for reporting. Fix will be included in release 3.0.5 next week.
Let us know if you have any other problem.
Using a GLOBAL value in predicates in more than one rule - rule fails
to evaluate correctly.
--------------------------------------------------------------------------------------------
Key: JBRULES-505
URL:
http://jira.jboss.com/jira/browse/JBRULES-505
Project: JBoss Rules
Issue Type: Bug
Security Level: Public(Everyone can see)
Components: All
Affects Versions: 3.0.4
Environment: Windows XP, JBoss 4.0.3SP1, JRules3.0.4,
PackageBuilderConfiguration.JANINO
Reporter: Matt Green
Assigned To: Edson Tirelli
Fix For: 3.0.5, 3.1-m1
SAMPLE CODE:
===============================================
package net.rockshore.rmf.rules
#list any import classes here.
import net.rockshore.rmf.entities.SubscriptionLocal;
import net.rockshore.rmf.entities.EventLocal;
import java.lang.String;
#declare any global variables here
global java.util.Collection resultsCollection;
global java.lang.String eventType;
rule "KeepSubscriptionsToEventType"
when
subscription : SubscriptionLocal (eventTypeDiscriminator == (eventType))
then
resultsCollection.add(subscription);
System.out.println("Keeping Subscription:" + subscription + " is of
type:" + eventType);
end
rule "DiscardSubscriptionsToWrongEventType"
when
wrongSubscription : SubscriptionLocal (eventTypeDiscriminator != (eventType))
then
System.out.println("Discarding Subscription:" + wrongSubscription + "
NOT of type:" + eventType);
retract (wrongSubscription);
end
===============================================
TEST DATA SET:
-------------------------
SubscriptionLocal objects asserted
KEY, EVENTTYPEDISCRIMINATOR
---------------------------------------------------------------------------------------------------------
5c4o12-mexdpy-esmukytr-1-esmx439o-58 ,
net.rockshore.rmf.entities.events.business.TravelAlertEvent
5c4o12-mexdpy-esmukytr-1-esmx438t-57 ,
net.rockshore.rmf.entities.events.business.FlightDelayEvent
5c4o12-mexdpy-esmukytr-1-esmx438t-56 ,
net.rockshore.rmf.entities.events.business.FlightDelayEvent
GLOBAL variable
eventType = "net.rockshore.rmf.entities.events.business.FlightDelayEvent"
PROBLEM DESCRIPTION:
-------------------------------------
When firing the above rules with data shown above, the result shows that
"DiscardSubscriptionsToWrongEventType" rule was fired for Subscriptions with
keys ending 57 and 56. This is the wrong way round as that rule should have fired only
with Subscription 58.
Further, rule "KeepSubscriptionsToEventType" did not fire.
FURTHER ANALYSIS:
-------------------------------
If one rule OR the other is deleted then the remaining rule fires correctly.
If both rules have the predicate replaced with a String literal
"net.rockshore.rmf.entities.events.business.FlightDelayEvent" then both rules
fire correctly.
The problem still occurs when eventType predicate is replaced with eventType.toString()
--
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