|
28 | 28 | import com.cloudbees.groovy.cps.Env; |
29 | 29 | import com.cloudbees.groovy.cps.Envs; |
30 | 30 | import com.cloudbees.groovy.cps.Outcome; |
31 | | -import com.cloudbees.groovy.cps.impl.ConstantBlock; |
32 | | -import com.cloudbees.groovy.cps.impl.ThrowBlock; |
33 | 31 | import com.cloudbees.groovy.cps.sandbox.Invoker; |
34 | 32 | import com.cloudbees.jenkins.support.api.Component; |
35 | 33 | import com.cloudbees.jenkins.support.api.Container; |
|
107 | 105 | import hudson.AbortException; |
108 | 106 | import hudson.BulkChange; |
109 | 107 | import hudson.Extension; |
| 108 | +import hudson.Functions; |
110 | 109 | import hudson.init.Terminator; |
111 | 110 | import hudson.model.Item; |
112 | 111 | import hudson.model.Job; |
@@ -840,51 +839,17 @@ public void onFailure(Throwable t) { |
840 | 839 | } |
841 | 840 |
|
842 | 841 | /** |
843 | | - * Used by {@link #loadProgramAsync(File)} to propagate a failure to load the persisted execution state. |
844 | | - * <p> |
845 | | - * Let the workflow interrupt by throwing an exception that indicates how it failed. |
| 842 | + * Used to propagate a failure to load the persisted execution state. |
846 | 843 | * @param promise same as {@link #programPromise} but more strongly typed |
847 | 844 | */ |
848 | 845 | private void loadProgramFailed(final Throwable problem, SettableFuture<CpsThreadGroup> promise) { |
849 | | - FlowHead head; |
850 | | - |
851 | | - synchronized(this) { |
852 | | - if (heads == null || heads.isEmpty()) { |
853 | | - head = null; |
854 | | - } else { |
855 | | - head = getFirstHead(); |
856 | | - } |
857 | | - } |
858 | | - |
859 | | - if (head==null) { |
860 | | - // something went catastrophically wrong and there's no live head. fake one |
861 | | - head = new FlowHead(this); |
862 | | - try { |
863 | | - head.newStartNode(new FlowStartNode(this, iotaStr())); |
864 | | - } catch (IOException e) { |
865 | | - LOGGER.log(Level.FINE, "Failed to persist", e); |
866 | | - } |
| 846 | + try { |
| 847 | + Functions.printStackTrace(problem, owner.getListener().getLogger()); |
| 848 | + } catch (Exception x) { |
| 849 | + LOGGER.log(Level.WARNING, x, () -> "failed to log problem to " + owner); |
867 | 850 | } |
868 | | - |
869 | | - |
870 | | - CpsThreadGroup g = new CpsThreadGroup(this); |
871 | | - final FlowHead head_ = head; |
872 | | - |
873 | | - promise.set(g); |
874 | | - runInCpsVmThread(new FutureCallback<>() { |
875 | | - @Override public void onSuccess(CpsThreadGroup g) { |
876 | | - CpsThread t = g.addThread( |
877 | | - new Continuable(new ThrowBlock(new ConstantBlock( |
878 | | - problem instanceof AbortException || problem instanceof FlowInterruptedException ? problem : new IOException("Failed to load build state", problem)))), |
879 | | - head_, null |
880 | | - ); |
881 | | - t.resume(new Outcome(null,null)); |
882 | | - } |
883 | | - @Override public void onFailure(Throwable t) { |
884 | | - LOGGER.log(Level.WARNING, "Failed to set program failure on " + owner, t); |
885 | | - croak(t); |
886 | | - } |
887 | | - }); |
| 851 | + promise.setException(problem); |
| 852 | + croak(new AbortException("Failed to load program")); |
888 | 853 | } |
889 | 854 |
|
890 | 855 | /** Report a fatal error in the VM. */ |
|
0 commit comments