Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[JEP-7] Comment updates after removing JRuby support #6224

Merged
merged 4 commits into from
Jan 31, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
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
4 changes: 1 addition & 3 deletions core/src/main/java/hudson/util/LogTaskListener.java
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 1 addition & 3 deletions core/src/main/java/hudson/util/StreamTaskListener.java
Original file line number Diff line number Diff line change
Expand Up @@ -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.
*
Expand All @@ -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;
Expand Down
12 changes: 0 additions & 12 deletions core/src/main/resources/hudson/model/Api/index.jelly
Original file line number Diff line number Diff line change
Expand Up @@ -84,18 +84,6 @@ THE SOFTWARE.
<code>ast.literal_eval(urllib.urlopen("...").read())</code>
</p>
</dd>

<!--
<dt><a href="ruby?pretty=true">Ruby API</a></dt>
<dd>
<p>
Access the same data as Ruby literals that can be <code>eval</code>ed.

However, when you do this, beware of the security implication. If you are connecting
to a non-trusted Jenkins, the server can send you malicious Python programs.
</p>
</dd>
-->
</dl>

<p>
Expand Down
25 changes: 25 additions & 0 deletions test/src/test/java/hudson/util/LogTaskListenerTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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<Void, RuntimeException> {

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;
}

}

}