mirror of https://github.com/apache/nifi.git
NIFI-362: Ensure that we synchronize on ScheduleState before modifying it
This commit is contained in:
parent
4cc106a54d
commit
f1e74cc041
|
@ -132,9 +132,14 @@ public class TimerDrivenSchedulingAgent implements SchedulingAgent {
|
|||
final long yieldNanos = TimeUnit.MILLISECONDS.toNanos(yieldMillis);
|
||||
final ScheduledFuture<?> newFuture = flowEngine.scheduleWithFixedDelay(this, yieldNanos,
|
||||
connectable.getSchedulingPeriod(TimeUnit.NANOSECONDS), TimeUnit.NANOSECONDS);
|
||||
|
||||
synchronized (scheduleState) {
|
||||
if ( scheduleState.isScheduled() ) {
|
||||
scheduleState.replaceFuture(scheduledFuture, newFuture);
|
||||
futureRef.set(newFuture);
|
||||
}
|
||||
}
|
||||
}
|
||||
} else if ( shouldYield ) {
|
||||
// Component itself didn't yield but there was no work to do, so the framework will choose
|
||||
// to yield the component automatically for a short period of time.
|
||||
|
@ -149,11 +154,16 @@ public class TimerDrivenSchedulingAgent implements SchedulingAgent {
|
|||
if (scheduledFuture.cancel(false)) {
|
||||
final ScheduledFuture<?> newFuture = flowEngine.scheduleWithFixedDelay(this, NO_WORK_YIELD_NANOS,
|
||||
connectable.getSchedulingPeriod(TimeUnit.NANOSECONDS), TimeUnit.NANOSECONDS);
|
||||
|
||||
synchronized (scheduleState) {
|
||||
if ( scheduleState.isScheduled() ) {
|
||||
scheduleState.replaceFuture(scheduledFuture, newFuture);
|
||||
futureRef.set(newFuture);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
// Schedule the task to run
|
||||
|
|
Loading…
Reference in New Issue