[jboss-svn-commits] JBL Code SVN: r37010 - labs/jbossrules/soa_branches/BRMS-5.1.x/drools-core/src/main/java/org/drools/common.

jboss-svn-commits at lists.jboss.org jboss-svn-commits at lists.jboss.org
Tue May 17 12:06:00 EDT 2011


Author: tsurdilovic
Date: 2011-05-17 12:06:00 -0400 (Tue, 17 May 2011)
New Revision: 37010

Modified:
   labs/jbossrules/soa_branches/BRMS-5.1.x/drools-core/src/main/java/org/drools/common/DefaultAgenda.java
Log:
BRMS-586: Rules do not fire according to salience after multiple fact updates

Modified: labs/jbossrules/soa_branches/BRMS-5.1.x/drools-core/src/main/java/org/drools/common/DefaultAgenda.java
===================================================================
--- labs/jbossrules/soa_branches/BRMS-5.1.x/drools-core/src/main/java/org/drools/common/DefaultAgenda.java	2011-05-17 15:51:13 UTC (rev 37009)
+++ labs/jbossrules/soa_branches/BRMS-5.1.x/drools-core/src/main/java/org/drools/common/DefaultAgenda.java	2011-05-17 16:06:00 UTC (rev 37010)
@@ -724,7 +724,7 @@
 
         // this is thread safe for BinaryHeapQueue
         // Binary Heap locks while it returns the array and reset's it's own internal array. Lock is released afer getAndClear()
-        final Activation[] queueable = ((InternalAgendaGroup) agendaGroup).getAndClear(); 
+        final Activation[] queueable = ((InternalAgendaGroup) agendaGroup).getAndClear();        
         for ( int i = 0, length = queueable.length; i < length; i++ ) {
             final AgendaItem item = (AgendaItem) queueable[i];
             if ( item == null ) {
@@ -925,32 +925,33 @@
                                                                             this.workingMemory,
                                                                             e );
                 } else if ( this.consequenceExceptionHandler != null ) {
-                    this.consequenceExceptionHandler.handleException( activation, this.workingMemory.getKnowledgeRuntime(),
+                    this.consequenceExceptionHandler.handleException( activation,
+                                                                      new StatefulKnowledgeSessionImpl( (ReteooWorkingMemory) this.workingMemory ),
                                                                       e );
                 } else {
                     throw new RuntimeException( e );
                 }
-            } finally {
-                // if the tuple contains expired events 
-                for ( LeftTuple tuple = (LeftTuple) activation.getTuple(); tuple != null; tuple = tuple.getParent() ) {
-                    if ( tuple.getLastHandle().isEvent() ) {
-                        EventFactHandle handle = (EventFactHandle) tuple.getLastHandle();
+            }
+            
+            if( ruleFlowGroup != null ) {
+                ruleFlowGroup.deactivateIfEmpty();
+            }
+
+            // if the tuple contains expired events 
+            for ( LeftTuple tuple = (LeftTuple) activation.getTuple(); tuple != null; tuple = tuple.getParent() ) {
+                if ( tuple.getLastHandle().isEvent() ) {
+                    EventFactHandle handle = (EventFactHandle) tuple.getLastHandle();
+                    // handles "expire" only in stream mode.
+                    if ( handle.isExpired() ) {
                         // decrease the activation count for the event
                         handle.decreaseActivationsCount();
-                        // handles "expire" only in stream mode.
-                        if ( handle.isExpired() ) {
-                            if ( handle.getActivationsCount() <= 0 ) {
-                                // and if no more activations, retract the handle
-                                handle.getEntryPoint().retract( handle );
-                            }
+                        if ( handle.getActivationsCount() == 0 ) {
+                            // and if no more activations, retract the handle
+                            handle.getEntryPoint().retract( handle );
                         }
                     }
                 }
             }
-            
-            if( ruleFlowGroup != null ) {
-                ruleFlowGroup.deactivateIfEmpty();
-            }
 
             eventsupport.getAgendaEventSupport().fireAfterActivationFired( activation,
                                                                            this.workingMemory );
@@ -1104,3 +1105,4 @@
         return this.legacyConsequenceExceptionHandler;
     }
 }
+



More information about the jboss-svn-commits mailing list