Skip to content

Commit e9a8d4e

Browse files
committed
[JENKINS-49707] BodyExecution.cancel overload taking actualInterruption
1 parent d896bf4 commit e9a8d4e

File tree

1 file changed

+14
-2
lines changed

1 file changed

+14
-2
lines changed

src/main/java/org/jenkinsci/plugins/workflow/steps/BodyExecution.java

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
*/
2424
package org.jenkinsci.plugins.workflow.steps;
2525

26+
import hudson.Util;
2627
import jenkins.model.CauseOfInterruption;
2728

2829
import 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

Comments
 (0)