Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,13 @@ public class ActionImpl implements SchedulableAction {
private ServiceDescription serviceDescription;
private volatile Future<ActionDescription> actionTask;

/**
* This flag ist required to handle the case when the action task was
* initiated but never started because of any interruption.
* In this case the flag is false but the actionTask non null.
*/
private volatile Boolean actionTaskRunning = false;

/**
* Constructor creates a new action object which helps to manage its execution during the scheduling process.
* <p>
Expand Down Expand Up @@ -198,7 +205,7 @@ private boolean isActionTaskFinished() {
// when the action task finishes it will finally reset the action task to null.
// actionTask.isDone(); is not a solution at all because when the action task is
// canceled then the method already returns true but the task is maybe still running.
return actionTask == null;
return actionTask == null || !actionTaskRunning;
}
}

Expand Down Expand Up @@ -256,7 +263,9 @@ public Future<ActionDescription> execute() {
new FatalImplementationErrorException("Action task still running while initializing a new one.", this);
}

actionTaskRunning = false;
actionTask = GlobalCachedExecutorService.submit(() -> {
actionTaskRunning = true;
try {

// validate operation service
Expand Down Expand Up @@ -362,6 +371,7 @@ public Future<ActionDescription> execute() {
}
} finally {
actionTask = null;
actionTaskRunning = false;
synchronized (actionTaskLock) {
actionTaskLock.notifyAll();
}
Expand Down Expand Up @@ -728,6 +738,14 @@ private void cancelActionTask() {
// cancel if exist
if (actionTask != null) {
actionTask.cancel(true);

// if the task is canceled before it is scheduled, we need to notify
// all waiting tasks about the cancellation
synchronized (actionTaskLock) {
if (!actionTaskRunning) {
actionTaskLock.notifyAll();
}
}
}

try {
Expand Down