Skip to content

Commit

Permalink
[JBRULES-3503] check if an activation is still enqueued before trying…
Browse files Browse the repository at this point in the history
… to remove it
  • Loading branch information
mariofusco committed May 11, 2012
1 parent 5bb2510 commit c7fb25c
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 5 deletions.
11 changes: 8 additions & 3 deletions drools-core/src/main/java/org/drools/common/DefaultAgenda.java
Expand Up @@ -264,6 +264,8 @@ public WorkingMemory getWorkingMemory() {
* The item to schedule.
*/
public void scheduleItem(final ScheduledAgendaItem item, final InternalWorkingMemory wm) {
this.scheduledActivations.add( item );
item.setEnqueued( true );
if( item.getPropagationContext().getReaderContext() == null ) {
// this is not a serialization propagation, so schedule it
// otherwise the timer will be correlated with this activation later during the
Expand All @@ -272,8 +274,6 @@ public void scheduleItem(final ScheduledAgendaItem item, final InternalWorkingMe
this,
wm );
}
this.scheduledActivations.add( item );
item.setEnqueued( true );
}


Expand Down Expand Up @@ -439,7 +439,12 @@ private void addActivation(AgendaItem item, boolean notify) {

final Timer timer = rule.getTimer();
if ( timer != null && item instanceof ScheduledAgendaItem ) {
scheduleItem( (ScheduledAgendaItem) item,
ScheduledAgendaItem sitem = (ScheduledAgendaItem) item;
if ( sitem.isEnqueued() ) {
// it's about to be re-added to scheduled list, so remove first
this.scheduledActivations.remove( sitem );
}
scheduleItem( sitem,
workingMemory );
} else {
InternalAgendaGroup agendaGroup = (InternalAgendaGroup) this.getAgendaGroup( rule.getAgendaGroup() );
Expand Down
6 changes: 4 additions & 2 deletions drools-core/src/main/java/org/drools/common/Scheduler.java
Expand Up @@ -90,8 +90,10 @@ public void execute(JobContext ctx) {
postpone(item, agenda);
}

agenda.getScheduledActivationsLinkedList().remove( item );
item.setEnqueued( false );
if ( item.isEnqueued() ) {
agenda.getScheduledActivationsLinkedList().remove( item );
item.setEnqueued( false );
}
} else {
// the activation has been rescheduled, the Agenda would have set it's activated to false
// so reset the activated to true here
Expand Down

0 comments on commit c7fb25c

Please sign in to comment.