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

Commit 8740a01

Browse files
committedMar 3, 2015
Merge pull request #65 from jglick/isReady-JENKINS-25890
[JENKINS-25890] Deadlock
2 parents 8fe11e0 + 790a545 commit 8740a01

File tree

5 files changed

+21
-9
lines changed

5 files changed

+21
-9
lines changed
 

‎CHANGES.md

+1
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ Only noting significant user-visible or major API changes, not internal code cle
55
## 1.3 (upcoming)
66

77
### User changes
8+
* JENKINS-25890: deadlock during restart.
89
* Fixed some file handle leaks caught by tests which may have affected Windows masters.
910
* JENKINS-25779: snippet generator now omits default values of complex steps.
1011
* Ability to configure project display name.

‎aggregator/src/test/java/org/jenkinsci/plugins/workflow/WorkflowTest.java

-1
Original file line numberDiff line numberDiff line change
@@ -650,7 +650,6 @@ public static void finish(final boolean terminate) {
650650
});
651651
}
652652

653-
@RandomlyFails("TODO JENKINS-25890 sometimes triggers a deadlock after restart")
654653
@Issue("JENKINS-26513")
655654
@Test public void executorStepRestart() {
656655
story.addStep(new Statement() {

‎cps/src/main/java/org/jenkinsci/plugins/workflow/cps/CpsBodySubContext.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ public void setResult(Result r) {
7474
}
7575

7676
@Override
77-
public boolean isReady() throws IOException, InterruptedException {
77+
public boolean isReady() {
7878
return base.isReady();
7979
}
8080

‎cps/src/main/java/org/jenkinsci/plugins/workflow/cps/CpsStepContext.java

+18-6
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@
5959
import java.util.concurrent.ExecutionException;
6060
import java.util.logging.Level;
6161
import java.util.logging.Logger;
62+
import jenkins.util.Timer;
6263
import org.codehaus.groovy.runtime.InvokerInvocationException;
6364

6465
import static org.jenkinsci.plugins.workflow.cps.persistence.PersistenceContext.*;
@@ -215,7 +216,7 @@ public String getDisplayName() {
215216
*
216217
* This can block for the entire duration of the PREPARING state.
217218
*/
218-
@CheckForNull CpsThread getThreadSynchronously() throws InterruptedException, IOException {
219+
private @CheckForNull CpsThread getThreadSynchronously() throws InterruptedException, IOException {
219220
try {
220221
CpsThreadGroup g = getProgramPromise().get();
221222
return getThread(g);
@@ -224,13 +225,24 @@ public String getDisplayName() {
224225
}
225226
}
226227

227-
private @Nonnull ListenableFuture<CpsThreadGroup> getProgramPromise() throws IOException {
228-
ListenableFuture<CpsThreadGroup> pp = getFlowExecution().programPromise;
229-
assert pp != null;
230-
return pp;
228+
private @Nonnull ListenableFuture<CpsThreadGroup> getProgramPromise() {
229+
final SettableFuture<CpsThreadGroup> f = SettableFuture.create();
230+
// TODO is there some more convenient way of writing this using Futures.transform?
231+
Timer.get().submit(new Runnable() {
232+
@Override public void run() {
233+
try {
234+
ListenableFuture<CpsThreadGroup> pp = getFlowExecution().programPromise;
235+
assert pp != null;
236+
f.set(pp.get());
237+
} catch (Exception x) { // from getFlowExecution() or get()
238+
f.setException(x);
239+
}
240+
}
241+
});
242+
return f;
231243
}
232244

233-
@Override public boolean isReady() throws IOException, InterruptedException {
245+
@Override public boolean isReady() {
234246
return getProgramPromise().isDone();
235247
}
236248

‎step-api/src/main/java/org/jenkinsci/plugins/workflow/steps/StepContext.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ public abstract class StepContext implements FutureCallback<Object>, Serializabl
8383
* May be called to break deadlocks during reloading.
8484
* @return true normally, false if we are still reloading the context, for example during unpickling
8585
*/
86-
public abstract boolean isReady() throws IOException, InterruptedException;
86+
public abstract boolean isReady();
8787

8888
/**
8989
* Requests that any state held by the {@link StepExecution} be saved to disk.

0 commit comments

Comments
 (0)