diff --git a/src/main/java/org/jenkinsci/plugins/workflow/steps/TimeoutStepExecution.java b/src/main/java/org/jenkinsci/plugins/workflow/steps/TimeoutStepExecution.java index ceefb2e9..ba6a97a4 100644 --- a/src/main/java/org/jenkinsci/plugins/workflow/steps/TimeoutStepExecution.java +++ b/src/main/java/org/jenkinsci/plugins/workflow/steps/TimeoutStepExecution.java @@ -336,11 +336,13 @@ private Object readResolve() { @Override public OutputStream decorateLogger(@SuppressWarnings("rawtypes") Run build, final OutputStream logger) throws IOException, InterruptedException { - // TODO if channel == null, we can safely ResetTimer.call synchronously from eol and skip the Tick AtomicBoolean active = new AtomicBoolean(); OutputStream decorated = new LineTransformationOutputStream() { @Override protected void eol(byte[] b, int len) throws IOException { + if (channel == null) { + new ResetTimer(id).call(); + } logger.write(b, 0, len); active.set(true); } @@ -357,7 +359,9 @@ public void close() throws IOException { logger.close(); } }; - new Tick(active, new WeakReference<>(decorated), timeout, channel, id).schedule(); + if (channel != null) { + new Tick(active, new WeakReference<>(decorated), timeout, channel, id).schedule(); + } return decorated; } }