Skip to content

Commit 3efd134

Browse files
authored
Merge pull request #466 from jglick/state-NPE
NPE in `ExecutorStepExecution$PlaceholderTask$Callback.finished`
2 parents 10879b0 + 71ee1b7 commit 3efd134

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

src/main/java/org/jenkinsci/plugins/workflow/support/steps/ExecutorStepExecution.java

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1031,10 +1031,13 @@ private static final class Callback extends BodyExecutionCallback.TailCall {
10311031
return;
10321032
}
10331033
LOGGER.log(FINE, "finished {0}", execution.getContext());
1034+
var state = execution.state;
10341035
try {
1035-
WorkspaceList.Lease _lease = ExtensionList.lookupSingleton(ExecutorStepDynamicContext.WorkspaceListLeaseTranslator.class).get(execution.state);
1036-
if (_lease != null) {
1037-
_lease.release();
1036+
if (state != null) {
1037+
WorkspaceList.Lease _lease = ExtensionList.lookupSingleton(ExecutorStepDynamicContext.WorkspaceListLeaseTranslator.class).get(state);
1038+
if (_lease != null) {
1039+
_lease.release();
1040+
}
10381041
}
10391042
} finally {
10401043
finish(execution.getContext(), cookie);
@@ -1045,7 +1048,9 @@ private static final class Callback extends BodyExecutionCallback.TailCall {
10451048
boolean _stopping = t.stopping;
10461049
t.stopping = true;
10471050
try {
1048-
if (Queue.getInstance().cancel(execution.state.task)) {
1051+
if (state == null) {
1052+
LOGGER.fine(() -> execution.getContext() + " not yet scheduled");
1053+
} else if (Queue.getInstance().cancel(state.task)) {
10491054
LOGGER.fine(() -> "cancelled leftover task from " + execution.getContext());
10501055
} else {
10511056
LOGGER.fine(() -> "was unable to cancel any leftover task from " + execution.getContext());

0 commit comments

Comments
 (0)