Bug 753770 - Declarative agenda activation canceling does not work in all iterations of StatefulKnowledgeSession
Summary: Declarative agenda activation canceling does not work in all iterations of St...
Keywords:
Status: VERIFIED
Alias: None
Product: JBoss Enterprise BRMS Platform 5
Classification: JBoss
Component: BRE (Expert, Fusion)
Version: BRMS 5.3.0.GA
Hardware: Unspecified
OS: Unspecified
unspecified
low
Target Milestone: ---
: BRMS 5.3.0.GA
Assignee: Mario Fusco
QA Contact: Marek Baluch
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2011-11-14 12:58 UTC by Jiri Svitak
Modified: 2020-04-27 01:12 UTC (History)
1 user (show)

Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Using declarative agenda, activation canceling with kcontext.cancelActivation(Activation) did not always work as expected and some activations were still fired even after they had been canceled. This issue was resolved by adding a canceled flag to the Activation which is set to true when the activation is canceled. This flag is checked for to ensure canceled activations are not re-added.
Clone Of:
Environment:
Last Closed:
Type: Bug
Embargoed:


Attachments (Terms of Use)
Test case to reproduce bug (1.92 KB, application/x-zip-compressed)
2011-11-14 12:58 UTC, Jiri Svitak
no flags Details
Corrected test case (1.39 KB, application/zip)
2011-11-21 13:51 UTC, Jiri Svitak
no flags Details


Links
System ID Private Priority Status Summary Last Updated
Red Hat Issue Tracker JBRULES-3442 0 Major Resolved Declarative agenda activation canceling does not work 2015-07-07 00:46:15 UTC

Description Jiri Svitak 2011-11-14 12:58:13 UTC
Created attachment 533517 [details]
Test case to reproduce bug

Description of problem:
Rule with enabled activation listener and working with activation facts is not fired first in the second iteration of StatefulKnowledgeSession. It is fired last and maybe that is the reason, that rule fired before is not canceled.

Version-Release number of selected component (if applicable):
BRMS 5.3.0 DEV4

How reproducible:
Fire rule that cancels activation of another rule in the second iteration. Quite difficult to explain, so use attached test case.

Steps to Reproduce:
1. Unzip and run attached test case.

  
Actual results:
In certain situations rule with activation listener set to 'direct' is not launched first. Maybe that is the cause why another specified rule is not canceled.

Expected results:
Rule with enabled direct activation listener should be fired first in all iterations of StatefulKnowledgeSession and should cancel rule that should be canceled.

Comment 1 Jiri Svitak 2011-11-21 13:51:33 UTC
Created attachment 534784 [details]
Corrected test case

Comment 2 Jiri Svitak 2011-11-21 14:01:54 UTC
Test case updated, because the first one had error. You can ignore my first comment.

Also bug reason is a bit different, but the bug summary is still correct - there is a problem with cancellation of a rule activation.

Test case explanation:
I use declarative agenda to cancel one rule in the first fireAllRules(). Everything works fine, specified rule is not fired.
But in the second iteration, I just update both inserted facts and the result is different. Specified rule is not cancelled and the cancelling rule is still fired and cancels nothing. Run the second test case to see this behaviour, which is in my opinion incorrect.

Comment 3 Jiri Svitak 2012-02-08 16:15:19 UTC
Added pull request with test case:
https://github.com/droolsjbpm/drools/pull/93

Comment 4 JBoss JIRA Server 2012-04-02 11:28:40 UTC
Mario Fusco <mario.fusco> updated the status of jira JBRULES-3442 to Resolved

Comment 5 Ryan Zhang 2012-04-23 07:39:39 UTC
Update status to ON_QA. Please verify them against ER6.

Comment 6 Jiri Svitak 2012-04-25 07:55:57 UTC
Verified in BRMS 5.3.0 ER6.

Comment 8 lcarlon 2012-06-01 03:39:46 UTC
    Technical note added. If any revisions are required, please edit the "Technical Notes" field
    accordingly. All revisions will be proofread by the Engineering Content Services team.
    
    New Contents:
Using declarative agenda, activation canceling with kcontext.cancelActivation(Activation) did not always work as expected and some activations were still fired even after they have been canceled.

Comment 9 lcarlon 2012-06-01 03:40:48 UTC
Hi Mario,

For the release notes could you let me know how this issue was resolved. We need to let customers know about any changes in the code that could affect their systems.

Thanks
Lee

Comment 10 Mario Fusco 2012-06-01 07:08:27 UTC
Hi Lee,

The fix was quite straightforward. I had to add a canceled flag to the Activation (actually to the AgendaItem that implements the Activation interface). Then I set this flag to true when the activation is canceled and in the DefaultAgenda I test it in order to avoid to readd canceled activation.

This is the commit that fixed the bug:

https://github.com/droolsjbpm/drools/commit/c27b0ad343fc51bdfaf2e16b7f4818aa3928dabe

Mario

Comment 11 lcarlon 2012-06-03 21:49:35 UTC
Thank you Mario.

Comment 12 lcarlon 2012-06-03 21:49:35 UTC
    Technical note updated. If any revisions are required, please edit the "Technical Notes" field
    accordingly. All revisions will be proofread by the Engineering Content Services team.
    
    Diffed Contents:
@@ -1 +1 @@
-Using declarative agenda, activation canceling with kcontext.cancelActivation(Activation) did not always work as expected and some activations were still fired even after they have been canceled.+Using declarative agenda, activation canceling with kcontext.cancelActivation(Activation) did not always work as expected and some activations were still fired even after they had been canceled.

Comment 13 lcarlon 2012-06-03 21:55:54 UTC
    Technical note updated. If any revisions are required, please edit the "Technical Notes" field
    accordingly. All revisions will be proofread by the Engineering Content Services team.
    
    Diffed Contents:
@@ -1 +1 @@
-Using declarative agenda, activation canceling with kcontext.cancelActivation(Activation) did not always work as expected and some activations were still fired even after they had been canceled.+Using declarative agenda, activation canceling with kcontext.cancelActivation(Activation) did not always work as expected and some activations were still fired even after they had been canceled. This issue was resolved by adding a canceled flag to the Activation which is set to true when the activation is canceled. This flag is checked for to ensure canceled activations are not re-added.


Note You need to log in before you can comment on or make changes to this bug.