Skip to content
Browse files

[JBRULES-3503] check if an activation is still enqueued before trying…

… to remove it
  • Loading branch information...
1 parent 5bb2510 commit c7fb25c559bebcc8fd4b828654380e6afa42dc3c @mariofusco mariofusco committed May 11, 2012
View
11 drools-core/src/main/java/org/drools/common/DefaultAgenda.java
@@ -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
@@ -272,8 +274,6 @@ public void scheduleItem(final ScheduledAgendaItem item, final InternalWorkingMe
this,
wm );
}
- this.scheduledActivations.add( item );
- item.setEnqueued( true );
}
@@ -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() );
View
6 drools-core/src/main/java/org/drools/common/Scheduler.java
@@ -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

0 comments on commit c7fb25c

Please sign in to comment.
Something went wrong with that request. Please try again.