Skip to content
Permalink
Browse files

[JENKINS-32986] Apply a timeout to some hang-prone operations in the …

…CPS VM thread.
  • Loading branch information
jglick committed Feb 5, 2017
1 parent 3ed45b6 commit c0deed0a3b546ebcb59ea25681ed3ac8b13fe6bb
@@ -28,7 +28,7 @@
<parent>
<groupId>org.jenkins-ci.plugins</groupId>
<artifactId>plugin</artifactId>
<version>2.19</version>
<version>2.21</version>
<relativePath />
</parent>
<groupId>org.jenkins-ci.plugins.workflow</groupId>
@@ -80,7 +80,7 @@
<dependency>
<groupId>org.jenkins-ci.plugins.workflow</groupId>
<artifactId>workflow-support</artifactId>
<version>2.11</version>
<version>2.13-20170205.153141-1</version> <!-- TODO https://github.com/jenkinsci/workflow-support-plugin/pull/29 -->
</dependency>
<dependency>
<groupId>${project.groupId}</groupId>
@@ -111,7 +111,7 @@
<dependency>
<groupId>org.jenkins-ci.plugins.workflow</groupId>
<artifactId>workflow-support</artifactId>
<version>2.9</version>
<version>2.13-20170205.153141-1</version> <!-- TODO https://github.com/jenkinsci/workflow-support-plugin/pull/29 -->
<classifier>tests</classifier>
<scope>test</scope>
</dependency>
@@ -29,6 +29,7 @@
import javax.annotation.concurrent.GuardedBy;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
import java.util.LinkedHashMap;
@@ -37,6 +38,7 @@
import java.util.concurrent.ExecutionException;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.TimeoutException;
import java.util.logging.Level;
import java.util.logging.Logger;

import static java.util.logging.Level.*;
@@ -264,7 +266,7 @@ public void onSuccess(CpsThreadGroup g) {

@Override
public void onFailure(Throwable t) {
// couldn't cancel
LOGGER.log(Level.WARNING, "could not cancel " + context + " with " + Arrays.toString(causes), t);
}
});
} else {
@@ -38,11 +38,13 @@
import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.Future;
import java.util.concurrent.TimeUnit;
import java.util.logging.Logger;

import static java.util.logging.Level.*;
import static org.jenkinsci.plugins.workflow.cps.persistence.PersistenceContext.*;
import org.jenkinsci.plugins.workflow.support.concurrent.Futures;
import org.jenkinsci.plugins.workflow.support.concurrent.Timeout;

/**
* Represents a {@link Continuable} that is either runnable or suspended (that waits for an
@@ -156,7 +158,7 @@ public StepExecution getStep() {
final CpsThread old = CURRENT.get();
CURRENT.set(this);

try {
try (Timeout timeout = Timeout.limit(5, TimeUnit.MINUTES)) {
LOGGER.log(FINE, "runNextChunk on {0}", resumeValue);
Outcome o = resumeValue;
resumeValue = null;
@@ -281,7 +283,7 @@ public void stop(Throwable t) {
return;
}

try {
try (Timeout timeout = Timeout.limit(30, TimeUnit.SECONDS)) {
s.stop(t);
} catch (Exception e) {
t.addSuppressed(e);

0 comments on commit c0deed0

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