Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Merge pull request #102 from jglick/Timeout-JENKINS-32986
[JENKINS-32986] Apply a timeout to some hang-prone operations in the CPS VM thread
  • Loading branch information
jglick committed Feb 13, 2017
2 parents 8da4ed3 + 3612527 commit 51c02d4
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 6 deletions.
6 changes: 3 additions & 3 deletions pom.xml
Expand Up @@ -28,7 +28,7 @@
<parent>
<groupId>org.jenkins-ci.plugins</groupId>
<artifactId>plugin</artifactId>
<version>2.19</version>
<version>2.22</version>
<relativePath />
</parent>
<groupId>org.jenkins-ci.plugins.workflow</groupId>
Expand Down Expand Up @@ -80,7 +80,7 @@
<dependency>
<groupId>org.jenkins-ci.plugins.workflow</groupId>
<artifactId>workflow-support</artifactId>
<version>2.11</version>
<version>2.13</version>
</dependency>
<dependency>
<groupId>${project.groupId}</groupId>
Expand Down Expand Up @@ -111,7 +111,7 @@
<dependency>
<groupId>org.jenkins-ci.plugins.workflow</groupId>
<artifactId>workflow-support</artifactId>
<version>2.9</version>
<version>2.13</version>
<classifier>tests</classifier>
<scope>test</scope>
</dependency>
Expand Down
Expand Up @@ -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;
Expand All @@ -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.*;
Expand Down Expand Up @@ -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 {
Expand Down
Expand Up @@ -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
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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);
Expand Down

0 comments on commit 51c02d4

Please sign in to comment.