Skip to content

Commit 03f7312

Browse files
authored
Merge pull request #373 from jglick/StepExecution.acceptAll
`StepExecutionIterator.accept`
2 parents 4fb69c3 + 9dc0011 commit 03f7312

File tree

3 files changed

+13
-7
lines changed

3 files changed

+13
-7
lines changed

pom.xml

+6
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,12 @@
7979
<scope>import</scope>
8080
<type>pom</type>
8181
</dependency>
82+
<!-- TODO until in BOM: -->
83+
<dependency>
84+
<groupId>org.jenkins-ci.plugins.workflow</groupId>
85+
<artifactId>workflow-step-api</artifactId>
86+
<version>686.v603d058a_e148</version>
87+
</dependency>
8288
</dependencies>
8389
</dependencyManagement>
8490
<dependencies>

src/main/java/org/jenkinsci/plugins/workflow/flow/FlowExecutionList.java

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
package org.jenkinsci.plugins.workflow.flow;
22

3-
import com.google.common.base.Function;
43
import com.google.common.collect.AbstractIterator;
54
import com.google.common.util.concurrent.FutureCallback;
65
import com.google.common.util.concurrent.Futures;
@@ -36,6 +35,7 @@
3635
import java.util.concurrent.CancellationException;
3736
import java.util.concurrent.RejectedExecutionException;
3837
import java.util.concurrent.TimeUnit;
38+
import java.util.function.Consumer;
3939
import java.util.logging.Level;
4040
import java.util.logging.Logger;
4141
import org.jenkinsci.plugins.workflow.graph.FlowNode;
@@ -313,7 +313,7 @@ private void save(List<FlowExecutionOwner> copy) {
313313
@Extension
314314
public static class StepExecutionIteratorImpl extends StepExecutionIterator {
315315
@Override
316-
public ListenableFuture<?> apply(final Function<StepExecution, Void> f) {
316+
public ListenableFuture<?> accept(Consumer<StepExecution> c) {
317317
List<ListenableFuture<?>> all = new ArrayList<>();
318318

319319
for (FlowExecution e : FlowExecutionList.get()) {
@@ -325,7 +325,7 @@ public ListenableFuture<?> apply(final Function<StepExecution, Void> f) {
325325
ListenableFuture<Void> results = Futures.transform(execs, (List<StepExecution> result) -> {
326326
for (StepExecution se : result) {
327327
try {
328-
f.apply(se);
328+
c.accept(se);
329329
} catch (RuntimeException x) {
330330
LOGGER.log(Level.WARNING, null, x);
331331
}

src/test/java/org/jenkinsci/plugins/workflow/flow/FlowExecutionListTest.java

+4-4
Original file line numberDiff line numberDiff line change
@@ -214,9 +214,9 @@ public class FlowExecutionListTest {
214214
stuck.setDefinition(new CpsFlowDefinition("blockSynchronously 'stuck'", false));
215215
var stuckBuild = stuck.scheduleBuild2(0).waitForStart();
216216
await().atMost(5, TimeUnit.SECONDS).until(() -> SynchronousBlockingStep.isStarted("stuck"));
217-
// Make FlowExecutionList$StepExecutionIteratorImpl.applyAll submit a task to the CpsVmExecutorService
217+
// Make FlowExecutionList$StepExecutionIteratorImpl.acceptAll submit a task to the CpsVmExecutorService
218218
// for stuck #1 that will never complete, so the resulting future will never complete.
219-
StepExecution.applyAll(e -> null);
219+
StepExecution.acceptAll(e -> {});
220220
// Let notStuckBuild complete and clean up all references.
221221
SemaphoreStep.success("wait/1", null);
222222
r.waitForCompletion(notStuckBuild);
@@ -248,9 +248,9 @@ public class FlowExecutionListTest {
248248
WeakReference<Object> notStuckBuildRef = new WeakReference<>(notStuckBuild);
249249
var stuck = r.jenkins.getItemByFullName("stuck", WorkflowJob.class);
250250
var stuckBuild = stuck.getBuildByNumber(1);
251-
// Make FlowExecutionList$StepExecutionIteratorImpl.applyAll submit a task to the CpsVmExecutorService
251+
// Make FlowExecutionList$StepExecutionIteratorImpl.acceptAll submit a task to the CpsVmExecutorService
252252
// for stuck #1 that will never complete, so the resulting future will never complete.
253-
StepExecution.applyAll(e -> null);
253+
StepExecution.acceptAll(e -> {});
254254
// Let notStuckBuild complete and clean up all references.
255255
SemaphoreStep.success("wait/1", null);
256256
r.waitForCompletion(notStuckBuild);

0 commit comments

Comments
 (0)