Skip to content

Commit

Permalink
Clean up warnings in tests about anonymous callable.
Browse files Browse the repository at this point in the history
Convert them to static, named classes.
  • Loading branch information
jeffret-b committed Oct 29, 2018
1 parent 6b84d7a commit 33220de
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 13 deletions.
8 changes: 4 additions & 4 deletions core/src/test/java/hudson/LauncherTest.java
Expand Up @@ -26,11 +26,11 @@

import hudson.model.StreamBuildListener;
import hudson.model.TaskListener;
import hudson.remoting.Callable;
import hudson.util.ProcessTree;
import hudson.util.StreamTaskListener;
import java.io.ByteArrayOutputStream;
import java.io.File;

import jenkins.security.MasterToSlaveCallable;
import org.apache.commons.io.FileUtils;
import static org.junit.Assert.*;
Expand Down Expand Up @@ -63,7 +63,7 @@ public class LauncherTest {
long end = System.currentTimeMillis();
long terminationTime = end - start;
assertTrue("Join did not finish promptly. The completion time (" + terminationTime + "ms) is longer than expected 15s", terminationTime < 15000);
channels.french.call(NOOP); // this only returns after the other side of the channel has finished executing cancellation
channels.french.call(new NoopCallable()); // this only returns after the other side of the channel has finished executing cancellation
Thread.sleep(2000); // more delay to make sure it's gone
assertNull("process should be gone",ProcessTree.get().get(Integer.parseInt(FileUtils.readFileToString(tmp).trim())));

Expand All @@ -76,11 +76,11 @@ public class LauncherTest {
// hangs and on slave machine pgrep sleep => one process; after manual kill, script returns.
}

private static final Callable<Object,RuntimeException> NOOP = new MasterToSlaveCallable<Object,RuntimeException>() {
private static class NoopCallable extends MasterToSlaveCallable<Object,RuntimeException> {
public Object call() throws RuntimeException {
return null;
}
};
}

@Issue("JENKINS-15733")
@Test public void decorateByEnv() throws Exception {
Expand Down
18 changes: 9 additions & 9 deletions core/src/test/java/hudson/os/SUTester.java
Expand Up @@ -5,19 +5,19 @@
import java.nio.file.Files;
import jenkins.security.MasterToSlaveCallable;

import java.io.FileOutputStream;

/**
* @author Kohsuke Kawaguchi
*/
public class SUTester {
public static void main(String[] args) throws Throwable {
SU.execute(StreamTaskListener.fromStdout(),"kohsuke","bogus",new MasterToSlaveCallable<Object, Throwable>() {
public Object call() throws Throwable {
System.out.println("Touching /tmp/x");
Files.newOutputStream(new File("/tmp/x").toPath()).close();
return null;
}
});
SU.execute(StreamTaskListener.fromStdout(),"kohsuke","bogus", new TouchingCallable());
}

private static class TouchingCallable extends MasterToSlaveCallable<Object, Throwable> {
public Object call() throws Throwable {
System.out.println("Touching /tmp/x");
Files.newOutputStream(new File("/tmp/x").toPath()).close();
return null;
}
}
}

0 comments on commit 33220de

Please sign in to comment.