|
1 | 1 | package org.jenkinsci.plugins.workflow.support.steps;
|
2 | 2 |
|
| 3 | +import com.google.common.util.concurrent.FutureCallback; |
| 4 | +import com.google.common.util.concurrent.Futures; |
| 5 | +import com.google.common.util.concurrent.MoreExecutors; |
3 | 6 | import edu.umd.cs.findbugs.annotations.CheckForNull;
|
4 | 7 | import edu.umd.cs.findbugs.annotations.NonNull;
|
5 | 8 | import edu.umd.cs.findbugs.annotations.Nullable;
|
|
65 | 68 | import org.jenkinsci.plugins.workflow.actions.LabelAction;
|
66 | 69 | import org.jenkinsci.plugins.workflow.actions.QueueItemAction;
|
67 | 70 | import org.jenkinsci.plugins.workflow.actions.ThreadNameAction;
|
| 71 | +import org.jenkinsci.plugins.workflow.flow.FlowExecution; |
68 | 72 | import org.jenkinsci.plugins.workflow.flow.FlowExecutionList;
|
69 | 73 | import org.jenkinsci.plugins.workflow.graph.FlowNode;
|
70 | 74 | import org.jenkinsci.plugins.workflow.steps.AbstractStepExecutionImpl;
|
@@ -363,12 +367,22 @@ private Object readResolve() {
|
363 | 367 | * Instead we keep only {@link #context} and look up the execution as needed.
|
364 | 368 | */
|
365 | 369 | private void withExecution(Consumer<ExecutorStepExecution> executionCallback) {
|
366 |
| - StepExecution.applyAll(ExecutorStepExecution.class, execution -> { |
367 |
| - if (execution.getContext().equals(context)) { |
368 |
| - executionCallback.accept(execution); |
369 |
| - } |
370 |
| - return null; |
371 |
| - }); |
| 370 | + try { |
| 371 | + Futures.addCallback(context.get(FlowExecution.class).getCurrentExecutions(false), new FutureCallback<List<StepExecution>>() { |
| 372 | + @Override public void onSuccess(List<StepExecution> result) { |
| 373 | + for (StepExecution execution : result) { |
| 374 | + if (execution instanceof ExecutorStepExecution && execution.getContext().equals(context)) { |
| 375 | + executionCallback.accept((ExecutorStepExecution) execution); |
| 376 | + } |
| 377 | + } |
| 378 | + } |
| 379 | + @Override public void onFailure(Throwable x) { |
| 380 | + LOGGER.log(Level.WARNING, null, x); |
| 381 | + } |
| 382 | + }, MoreExecutors.directExecutor()); |
| 383 | + } catch (IOException | InterruptedException x) { |
| 384 | + LOGGER.log(Level.WARNING, null, x); |
| 385 | + } |
372 | 386 | }
|
373 | 387 |
|
374 | 388 | /**
|
|
0 commit comments