Skip to content

Commit 79763b5

Browse files
authored
Merge pull request #540 from jglick/CpsVmExecutorService.shutdown
Call `CpsVmExecutorService.shutdown` from `CpsFlowExecution.suspendAll`
2 parents aa9dcde + 25298d7 commit 79763b5

File tree

4 files changed

+15
-5
lines changed

4 files changed

+15
-5
lines changed

src/main/java/org/jenkinsci/plugins/workflow/cps/CpsFlowExecution.java

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1649,6 +1649,15 @@ public void pause(final boolean v) throws IOException {
16491649
}
16501650
}
16511651
cpsExec.checkpoint(true);
1652+
cpsExec.runInCpsVmThread(new FutureCallback<CpsThreadGroup>() {
1653+
@Override public void onSuccess(CpsThreadGroup g) {
1654+
LOGGER.fine(() -> "shutting down CPS VM threadin for " + cpsExec);
1655+
g.shutdown();
1656+
}
1657+
@Override public void onFailure(Throwable t) {
1658+
LOGGER.log(Level.WARNING, null, t);
1659+
}
1660+
});
16521661
}
16531662
} catch (Exception ex) {
16541663
LOGGER.log(Level.WARNING, "Error persisting Pipeline execution at shutdown: "+((CpsFlowExecution) execution).owner, ex);

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

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -430,12 +430,9 @@ public void onSuccess(CpsThreadGroup g) {
430430
}
431431
outcome = new Outcome(null, new AlreadyCompleted());
432432
}
433-
434-
/**
435-
* Program state failed to load.
436-
*/
437433
@Override
438434
public void onFailure(Throwable t) {
435+
LOGGER.log(Level.WARNING, "Failed to proceed after " + CpsStepContext.this, t);
439436
}
440437
});
441438
} catch (IOException x) {

src/main/java/org/jenkinsci/plugins/workflow/cps/CpsThreadGroup.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -640,6 +640,10 @@ private void propagateErrorToWorkflow(Throwable t) {
640640
}
641641
}
642642

643+
void shutdown() {
644+
runner.shutdown();
645+
}
646+
643647
private static final Logger LOGGER = Logger.getLogger(CpsThreadGroup.class.getName());
644648

645649
private static final long serialVersionUID = 1L;

src/main/java/org/jenkinsci/plugins/workflow/cps/CpsVmExecutorService.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,7 @@ private void tearDown(ThreadContext context) {
166166
cpsThreadGroup.busy = false;
167167
context.restore();
168168
CpsFlowExecution execution = cpsThreadGroup.getExecution();
169-
if (isShutdown()) {
169+
if (isShutdown() && /* build completed, not just after suspendAll */!cpsThreadGroup.getThreads().iterator().hasNext()) {
170170
execution.logTimings();
171171
}
172172
CpsCallableInvocation.registerMismatchHandler(null);

0 commit comments

Comments
 (0)