Skip to content
This repository has been archived by the owner on Dec 15, 2021. It is now read-only.

Commit

Permalink
[JENKINS-25890] Refined fix to use its own thread pool, not jenkins.u…
Browse files Browse the repository at this point in the history
…til.Timer.
  • Loading branch information
jglick committed Mar 3, 2015
1 parent 35aa4cf commit c16a522
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
Expand Up @@ -427,6 +427,7 @@ public void onSuccess(Unmarshaller u) {
}

public void onFailure(Throwable t) {
// Note: not calling result.setException(t) since loadProgramFailed in fact sets a result
try {
loadProgramFailed(t, result);
} finally {
Expand Down
Expand Up @@ -31,6 +31,8 @@
import groovy.lang.Closure;
import hudson.model.Descriptor;
import hudson.model.Result;
import hudson.util.DaemonThreadFactory;
import hudson.util.NamingThreadFactory;
import jenkins.model.Jenkins;
import org.jenkinsci.plugins.workflow.cps.nodes.StepEndNode;
import org.jenkinsci.plugins.workflow.cps.nodes.StepStartNode;
Expand All @@ -57,9 +59,10 @@
import java.util.Collections;
import java.util.List;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.logging.Level;
import java.util.logging.Logger;
import jenkins.util.Timer;
import org.codehaus.groovy.runtime.InvokerInvocationException;

import static org.jenkinsci.plugins.workflow.cps.persistence.PersistenceContext.*;
Expand Down Expand Up @@ -224,11 +227,12 @@ public String getDisplayName() {
throw new IOException(e);
}
}


private static final ExecutorService getProgramPromiseExecutorService = Executors.newCachedThreadPool(new NamingThreadFactory(new DaemonThreadFactory(), "CpsStepContext.getProgramPromise"));
private @Nonnull ListenableFuture<CpsThreadGroup> getProgramPromise() {
final SettableFuture<CpsThreadGroup> f = SettableFuture.create();
// TODO is there some more convenient way of writing this using Futures.transform?
Timer.get().submit(new Runnable() {
// TODO is there some more convenient way of writing this using Futures.transform? FlowExecutionOwner.get should really return ListenableFuture<FlowExecution>
getProgramPromiseExecutorService.submit(new Runnable() {
@Override public void run() {
try {
ListenableFuture<CpsThreadGroup> pp = getFlowExecution().programPromise;
Expand Down

0 comments on commit c16a522

Please sign in to comment.