@@ -1653,24 +1653,25 @@ public static void suspendAll() {
16531653 try (Timeout t = Timeout .limit (3 , TimeUnit .MINUTES )) { // TODO some complicated sequence of calls to Futures could allow all of them to run in parallel
16541654 LOGGER .fine ("starting to suspend all executions" );
16551655 for (FlowExecution execution : FlowExecutionList .get ()) {
1656- if (execution instanceof CpsFlowExecution ) {
1657- CpsFlowExecution cpsExec = (CpsFlowExecution ) execution ;
1656+ if (execution instanceof CpsFlowExecution cpsExec ) {
16581657 try {
16591658 cpsExec .checkAndAbortNonresumableBuild ();
16601659
1661- LOGGER . log ( Level . FINE , "waiting to suspend {0}" , execution ) ;
1660+ var programPromise = cpsExec . programPromise ;
16621661 // Like waitForSuspension but with a timeout:
1663- if (cpsExec . programPromise != null ) {
1664- LOGGER .log ( Level . FINER , "Waiting for Pipeline to go to sleep for shutdown: " + execution );
1662+ if (programPromise != null && programPromise . isDone () ) {
1663+ LOGGER .fine (() -> "waiting to suspend " + execution );
16651664 try {
1666- cpsExec . programPromise .get (1 , TimeUnit . MINUTES ).scheduleRun ().get (1 , TimeUnit .MINUTES );
1665+ programPromise .get ().scheduleRun ().get (1 , TimeUnit .MINUTES );
16671666 LOGGER .log (Level .FINER , " Pipeline went to sleep OK: " +execution );
16681667 } catch (InterruptedException | TimeoutException ex ) {
16691668 LOGGER .log (Level .WARNING , "Error waiting for Pipeline to suspend: " + cpsExec , ex );
16701669 }
1670+ } else {
1671+ LOGGER .fine (() -> "not trying to suspend " + execution );
16711672 }
16721673 cpsExec .checkpoint (true );
1673- if (cpsExec . programPromise != null ) {
1674+ if (programPromise != null ) {
16741675 cpsExec .runInCpsVmThread (new FutureCallback <>() {
16751676 @ Override public void onSuccess (CpsThreadGroup g ) {
16761677 LOGGER .fine (() -> "shutting down CPS VM for " + cpsExec );
0 commit comments