Skip to content
Permalink
Browse files

[JENKINS-39072] Print log messages about what is happening with timeo…

…uts.
  • Loading branch information
jglick committed Oct 18, 2016
1 parent 2cbd8fd commit f36a5c382fbdfc7bc2b0d98430f34ace03375b40
Showing with 13 additions and 3 deletions.
  1. +13 −3 src/main/java/org/jenkinsci/plugins/workflow/steps/TimeoutStepExecution.java
@@ -2,6 +2,8 @@

import com.google.inject.Inject;
import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
import hudson.Util;
import hudson.model.TaskListener;
import java.util.concurrent.ScheduledFuture;
import java.util.concurrent.TimeUnit;

@@ -15,6 +17,7 @@
public class TimeoutStepExecution extends AbstractStepExecutionImpl {
@Inject(optional=true)
private transient TimeoutStep step;
@StepContextParameter private transient TaskListener listener;
private BodyExecution body;
private transient ScheduledFuture<?> killer;

@@ -45,17 +48,24 @@ public void onResume() {
*/
private void setupTimer(final long now) {
if (end > now) {
long delay = end - now;
listener.getLogger().println("Timeout set to expire in " + Util.getTimeSpanString(delay));
killer = Timer.get().schedule(new Runnable() {
@Override
public void run() {
body.cancel(new ExceededTimeout());
cancel();
}
}, end - now, TimeUnit.MILLISECONDS);
}, delay, TimeUnit.MILLISECONDS);
} else {
body.cancel(new ExceededTimeout());
cancel();
}
}

private void cancel() {
listener.getLogger().println("Cancelling nested steps due to timeout");
body.cancel(new ExceededTimeout());
}

@Override
public void stop(Throwable cause) throws Exception {
if (body!=null)

0 comments on commit f36a5c3

Please sign in to comment.
You can’t perform that action at this time.