[jboss-jira] [JBoss JIRA] Created: (JBRULES-505) Using a GLOBAL value in predicates in more than one rule - rule fails to evaluate correctly.
Matt Green (JIRA)
jira-events at jboss.com
Thu Sep 28 05:27:41 EDT 2006
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: Mark Proctor
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
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
More information about the jboss-jira
mailing list