Skip to content
Permalink
Browse files

[FIXED JENKINS-25890] isReady should not block, so getProgramPromise …

…may not block on getFlowExecution.

Originally-Committed-As: 790a5453ef094da16e906acc5b5cc512ac1bde60
  • Loading branch information...
jglick committed Mar 2, 2015
1 parent 66fcf94 commit 32e4663331d273928301d699698ac59df3e46d77
@@ -650,7 +650,6 @@ public static void finish(final boolean terminate) {
});
}

@RandomlyFails("TODO JENKINS-25890 sometimes triggers a deadlock after restart")
@Issue("JENKINS-26513")
@Test public void executorStepRestart() {
story.addStep(new Statement() {
@@ -74,7 +74,7 @@ public void setResult(Result r) {
}

@Override
public boolean isReady() throws IOException, InterruptedException {
public boolean isReady() {
return base.isReady();
}

@@ -59,6 +59,7 @@
import java.util.concurrent.ExecutionException;
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.*;
@@ -215,7 +216,7 @@ public String getDisplayName() {
*
* This can block for the entire duration of the PREPARING state.
*/
@CheckForNull CpsThread getThreadSynchronously() throws InterruptedException, IOException {
private @CheckForNull CpsThread getThreadSynchronously() throws InterruptedException, IOException {
try {
CpsThreadGroup g = getProgramPromise().get();
return getThread(g);
@@ -224,13 +225,24 @@ public String getDisplayName() {
}
}

private @Nonnull ListenableFuture<CpsThreadGroup> getProgramPromise() throws IOException {
ListenableFuture<CpsThreadGroup> pp = getFlowExecution().programPromise;
assert pp != null;
return pp;
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() {
@Override public void run() {
try {
ListenableFuture<CpsThreadGroup> pp = getFlowExecution().programPromise;
assert pp != null;
f.set(pp.get());
} catch (Exception x) { // from getFlowExecution() or get()
f.setException(x);
}
}
});
return f;
}

@Override public boolean isReady() throws IOException, InterruptedException {
@Override public boolean isReady() {
return getProgramPromise().isDone();
}

0 comments on commit 32e4663

Please sign in to comment.
You can’t perform that action at this time.