Skip to content

Commit

Permalink
Merge pull request #100 from jglick/Timer
Browse files Browse the repository at this point in the history
[JENKINS-40613] Report a blocked Timer
  • Loading branch information
jglick committed Jan 26, 2017
2 parents b131f68 + aac29d0 commit b7c48db
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions src/main/java/com/cloudbees/jenkins/support/impl/ThreadDumps.java
Expand Up @@ -36,10 +36,12 @@
import java.util.Map;
import java.util.Set;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.ScheduledThreadPoolExecutor;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.TimeoutException;
import java.util.logging.Level;
import java.util.logging.Logger;
import jenkins.util.Timer;

/**
* Thread dumps from the nodes.
Expand Down Expand Up @@ -77,6 +79,17 @@ public void writeTo(OutputStream os) throws IOException {
} finally {
out.flush();
}
try {
Timer.get().submit(new Runnable() {
@Override
public void run() {/* OK */}
}).get(10, TimeUnit.SECONDS);
} catch (ExecutionException | InterruptedException x) {
logger.log(Level.WARNING, null, x);
} catch (TimeoutException x) {
ScheduledThreadPoolExecutor timer = (ScheduledThreadPoolExecutor) Timer.get();
out.println("*WARNING*: jenkins.util.Timer is unresponsive; pool size " + timer.getPoolSize() + " vs. active count " + timer.getActiveCount());
}
try {
threadDump(os);
} finally {
Expand Down

0 comments on commit b7c48db

Please sign in to comment.