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

Commit

Permalink
Browse files Browse the repository at this point in the history
Merge pull request #323 from jglick/quick-node-JENKINS-30759
[JENKINS-30759] Race condition initializing fields in RunningTask
  • Loading branch information
jglick committed Jan 25, 2016
2 parents 0bf6742 + e0fe19d commit 10b3bc8
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 2 deletions.
1 change: 1 addition & 0 deletions CHANGES.md
Expand Up @@ -5,6 +5,7 @@ Only noting significant user changes, not internal code cleanups and minor bug f
## 1.14 (upcoming)

* [JENKINS-32547](https://issues.jenkins-ci.org/browse/JENKINS-32547): laxer timeout on `bat` step log collection is needed for WinRM-based EC2 slaves.
* [JENKINS-30759](https://issues.jenkins-ci.org/browse/JENKINS-30759): sporadic `NullPointerException`s running very short-lived `node` blocks.

## 1.13 (Jan 18 2016)

Expand Down
Expand Up @@ -415,4 +415,15 @@ private void startJnlpProc() throws Exception {
});
}

@Issue("JENKINS-30759")
@Test public void quickNodeBlock() {
story.addStep(new Statement() {
@Override public void evaluate() throws Throwable {
p = jenkins().createProject(WorkflowJob.class, "demo");
p.setDefinition(new CpsFlowDefinition("for (int i = 0; i < 50; i++) {node {echo \"ran node block #${i}\"}}"));
story.j.assertLogContains("ran node block #49", story.j.assertBuildStatusSuccess(p.scheduleBuild2(0)));
}
});
}

}
Expand Up @@ -362,7 +362,11 @@ private static void finish(@CheckForNull String cookie) {
return;
}
final AsynchronousExecution execution = runningTask.execution;
assert execution != null && runningTask.launcher != null;
if (execution == null) {
// JENKINS-30759: finished before asynch execution was even scheduled
return;
}
assert runningTask.launcher != null;
Timer.get().submit(new Runnable() { // JENKINS-31614
@Override public void run() {
execution.completed(null);
Expand Down Expand Up @@ -478,7 +482,10 @@ private final class PlaceholderExecutable implements ContinuableExecutable {
synchronized (runningTasks) {
LOGGER.log(FINE, "waiting on {0}", cookie);
RunningTask runningTask = runningTasks.get(cookie);
assert runningTask != null : "no entry for " + cookie + " among " + runningTasks.keySet();
if (runningTask == null) {
LOGGER.log(FINE, "running task apparently finished quickly for {0}", cookie);
return;
}
assert runningTask.execution == null;
assert runningTask.launcher == null;
runningTask.launcher = launcher;
Expand Down

0 comments on commit 10b3bc8

Please sign in to comment.