Skip to content
Merged
Changes from 1 commit
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 @@ -889,7 +889,7 @@ public boolean equals(Object obj) {
}

private static void finish(StepContext context, @CheckForNull final String cookie) {
RunningTask runningTask = RunningTasks.get(context, t -> t, () -> null);
RunningTask runningTask = RunningTasks.get(context);
if (runningTask == null) {
LOGGER.fine(() -> "no known running task for " + context);
return;
Expand Down Expand Up @@ -952,7 +952,7 @@ private static final class Callback extends BodyExecutionCallback.TailCall {
finish(execution.getContext(), cookie);
}
execution.body = null;
RunningTask t = RunningTasks.remove(execution.getContext());
RunningTask t = RunningTasks.get(execution.getContext());
if (t != null) {
LOGGER.fine(() -> "cancelling any leftover task from " + execution.getContext());
boolean _stopping = t.stopping;
Expand All @@ -967,6 +967,7 @@ private static final class Callback extends BodyExecutionCallback.TailCall {
}
execution.state = null;
bodyContext.saveState();
RunningTasks.remove(execution.getContext());
}

}
Expand Down Expand Up @@ -1239,6 +1240,10 @@ static <T> T get(StepContext context, Function<RunningTask, T> fn, Supplier<T> f
}
}

static @CheckForNull RunningTask get(StepContext context) {
return get(context, t -> t, () -> null);
}

static void run(StepContext context, Consumer<RunningTask> fn) {
RunningTask t = find(context);
if (t != null) {
Expand All @@ -1248,10 +1253,12 @@ static void run(StepContext context, Consumer<RunningTask> fn) {
}
}

static @CheckForNull RunningTask remove(StepContext context) {
static void remove(StepContext context) {
RunningTasks holder = ExtensionList.lookupSingleton(RunningTasks.class);
synchronized (holder) {
return holder.runningTasks.remove(context);
if (holder.runningTasks.remove(context) == null) {
LOGGER.fine(() -> "no RunningTask to remove associated with " + context);
}
}
}

Expand Down