Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PlaceholderTask.Callback.finished did not correctly suppress CancelledItemListener, and willContinue was unreliable #355

Merged
merged 4 commits into from
Feb 2, 2024
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 @@
}

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 @@
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 @@
}
execution.state = null;
bodyContext.saveState();
RunningTasks.remove(execution.getContext());
}

}
Expand Down Expand Up @@ -1239,6 +1240,10 @@
}
}

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 @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) {

Check warning on line 1259 in src/main/java/org/jenkinsci/plugins/workflow/support/steps/ExecutorStepExecution.java

View check run for this annotation

ci.jenkins.io / Code Coverage

Partially covered line

Line 1259 is only partially covered, one branch is missing
LOGGER.fine(() -> "no RunningTask to remove associated with " + context);

Check warning on line 1260 in src/main/java/org/jenkinsci/plugins/workflow/support/steps/ExecutorStepExecution.java

View check run for this annotation

ci.jenkins.io / Code Coverage

Not covered line

Line 1260 is not covered by tests
}
}
}

Expand Down