Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,8 @@
import hudson.model.TaskListener;
import hudson.remoting.Channel;
import hudson.remoting.ChannelClosedException;
import hudson.util.DaemonThreadFactory;
import hudson.util.FormValidation;
import hudson.util.LogTaskListener;
import hudson.util.NamingThreadFactory;
import hudson.util.StreamTaskListener;
import java.io.FilterOutputStream;
import java.io.IOException;
Expand All @@ -51,7 +49,6 @@
import java.nio.charset.StandardCharsets;
import java.util.Set;
import java.util.concurrent.ScheduledFuture;
import java.util.concurrent.ScheduledThreadPoolExecutor;
import java.util.concurrent.TimeUnit;
import java.util.logging.Level;
import java.util.logging.Logger;
Expand Down Expand Up @@ -205,12 +202,6 @@ static final class Execution extends AbstractStepExecutionImpl implements Runnab
private static final long MAX_RECURRENCE_PERIOD = 15000; // 15s
private static final float RECURRENCE_PERIOD_BACKOFF = 1.2f;

private static final ScheduledThreadPoolExecutor THREAD_POOL = new ScheduledThreadPoolExecutor(25, new NamingThreadFactory(new DaemonThreadFactory(), DurableTaskStep.class.getName()));
static {
THREAD_POOL.setKeepAliveTime(1, TimeUnit.MINUTES);
THREAD_POOL.allowCoreThreadTimeOut(true);
}

/** Used only during {@link #start}. */
private transient final DurableTaskStep step;
/** Current “live” connection to the workspace, or null if we might be offline at the moment. */
Expand Down Expand Up @@ -410,11 +401,9 @@ private void getWorkspaceProblem(Exception x) {
task = null;
try (WithThreadName naming = new WithThreadName(": checking " + remote + " on " + node)) {
check();
} catch (Exception x) { // TODO use ErrorLoggingScheduledThreadPoolExecutor from core if it becomes public
LOGGER.log(Level.WARNING, null, x);
} finally {
if (recurrencePeriod > 0) {
task = THREAD_POOL.schedule(this, recurrencePeriod, TimeUnit.MILLISECONDS);
task = Timer.get().schedule(this, recurrencePeriod, TimeUnit.MILLISECONDS);
}
}
}
Expand Down Expand Up @@ -529,7 +518,7 @@ private void check() {

private void setupTimer(long initialRecurrencePeriod) {
recurrencePeriod = initialRecurrencePeriod;
task = THREAD_POOL.schedule(this, recurrencePeriod, TimeUnit.MILLISECONDS);
task = Timer.get().schedule(this, recurrencePeriod, TimeUnit.MILLISECONDS);
}

private static final long serialVersionUID = 1L;
Expand Down