diff --git a/core/src/main/java/hudson/util/LogTaskListener.java b/core/src/main/java/hudson/util/LogTaskListener.java index 7d696ada4632..267f8f7bf27f 100644 --- a/core/src/main/java/hudson/util/LogTaskListener.java +++ b/core/src/main/java/hudson/util/LogTaskListener.java @@ -37,12 +37,10 @@ import java.util.logging.LogRecord; import java.util.logging.Logger; -// TODO: AbstractTaskListener is empty now, but there are dependencies on that e.g. Ruby Runtime - JENKINS-48116) -// The change needs API deprecation policy or external usages cleanup. - /** * {@link TaskListener} which sends messages to a {@link Logger}. */ +@SuppressWarnings("deprecation") // to preserve serial form public class LogTaskListener extends AbstractTaskListener implements TaskListener, Closeable { // would be simpler to delegate to the LogOutputStream but this would incompatibly change the serial form diff --git a/core/src/main/java/hudson/util/StreamTaskListener.java b/core/src/main/java/hudson/util/StreamTaskListener.java index 8aad40f5b599..f19db94b45cd 100644 --- a/core/src/main/java/hudson/util/StreamTaskListener.java +++ b/core/src/main/java/hudson/util/StreamTaskListener.java @@ -48,9 +48,6 @@ import jenkins.util.SystemProperties; import org.kohsuke.stapler.framework.io.WriterOutputStream; -// TODO: AbstractTaskListener is empty now, but there are dependencies on that e.g. Ruby Runtime - JENKINS-48116) -// The change needs API deprecation policy or external usages cleanup. - /** * {@link TaskListener} that generates output into a single stream. * @@ -59,6 +56,7 @@ * * @author Kohsuke Kawaguchi */ +@SuppressWarnings("deprecation") // to preserve serial form public class StreamTaskListener extends AbstractTaskListener implements TaskListener, Closeable { @NonNull private PrintStream out; diff --git a/core/src/main/resources/hudson/model/Api/index.jelly b/core/src/main/resources/hudson/model/Api/index.jelly index b927eafb513d..cc208c986d7d 100644 --- a/core/src/main/resources/hudson/model/Api/index.jelly +++ b/core/src/main/resources/hudson/model/Api/index.jelly @@ -84,18 +84,6 @@ THE SOFTWARE. ast.literal_eval(urllib.urlopen("...").read())

- -

diff --git a/test/src/test/java/hudson/util/LogTaskListenerTest.java b/test/src/test/java/hudson/util/LogTaskListenerTest.java index 72b89f64a205..f1dad026f5d6 100644 --- a/test/src/test/java/hudson/util/LogTaskListenerTest.java +++ b/test/src/test/java/hudson/util/LogTaskListenerTest.java @@ -30,6 +30,7 @@ import hudson.model.TaskListener; import java.util.logging.Level; import java.util.logging.Logger; +import jenkins.security.MasterToSlaveCallable; import org.junit.Rule; import org.junit.Test; import org.jvnet.hudson.test.JenkinsRule; @@ -56,4 +57,28 @@ public void annotations() throws Exception { assertEquals("[plain line, from annotate, from hyperlink, there from encoded]", logging.getMessages().toString()); } + @Test + public void serialization() throws Exception { + TaskListener l = new LogTaskListener(Logger.getLogger("LogTaskListenerTest"), Level.INFO); + r.createOnlineSlave().getChannel().call(new Log(l)); + assertEquals("[from agent]", logging.getMessages().toString()); + } + + private static final class Log extends MasterToSlaveCallable { + + private final TaskListener l; + + Log(TaskListener l) { + this.l = l; + } + + @Override + public Void call() throws RuntimeException { + l.getLogger().println("from agent"); + l.getLogger().flush(); + return null; + } + + } + }