2323 */
2424package org .jenkinsci .plugins .workflow .steps ;
2525
26+ import hudson .Util ;
2627import jenkins .model .CauseOfInterruption ;
2728
2829import java .io .Serializable ;
@@ -57,8 +58,19 @@ public abstract class BodyExecution implements Future<Object>, Serializable {
5758 * has happened or completed before this method returns.
5859 *
5960 * @return false if the task cannot be cancelled.
61+ * @deprecated use {@link #cancel(boolean, CauseOfInterruption...)}
6062 */
61- public abstract boolean cancel (CauseOfInterruption ... causes );
63+ public boolean cancel (CauseOfInterruption ... causes ) {
64+ return cancel (true , causes );
65+ }
66+
67+ public boolean cancel (boolean actualInterruption , CauseOfInterruption ... causes ) {
68+ if (Util .isOverridden (BodyExecution .class , getClass (), "cancel" , CauseOfInterruption [].class )) {
69+ return cancel (causes );
70+ } else {
71+ throw new AbstractMethodError ("Override cancel(boolean, CauseOfInterruption...) from " + getClass ());
72+ }
73+ }
6274
6375 /**
6476 * @deprecated
@@ -73,7 +85,7 @@ public boolean cancel(boolean b) {
7385 * the cause is a random exception.
7486 */
7587 public boolean cancel (Throwable t ) {
76- return cancel (new ExceptionCause (t ));
88+ return cancel (t instanceof FlowInterruptedException ? (( FlowInterruptedException ) t ). isActualInterruption () : false , new ExceptionCause (t ));
7789 }
7890
7991 private static final long serialVersionUID = 1L ;
0 commit comments