From ffb5b65093bb2afd5832cac4ea6799409abc05c4 Mon Sep 17 00:00:00 2001 From: Kohsuke Kawaguchi Date: Tue, 23 Sep 2014 18:33:56 -0700 Subject: [PATCH] Switched from annotation based scheme to a function based scheme. --- core/src/main/java/hudson/EnvVars.java | 5 +- core/src/main/java/hudson/FilePath.java | 144 ++++++++++++------ core/src/main/java/hudson/Launcher.java | 11 +- core/src/main/java/hudson/cli/CLICommand.java | 12 +- .../java/hudson/cli/CommandDuringBuild.java | 5 +- .../java/hudson/cli/InstallToolCommand.java | 8 +- .../java/hudson/cli/util/ScriptLoader.java | 6 +- .../main/java/hudson/logging/LogRecorder.java | 5 +- .../main/java/hudson/model/AbstractItem.java | 4 +- core/src/main/java/hudson/model/Computer.java | 11 +- core/src/main/java/hudson/model/Slave.java | 9 +- .../node_monitors/ArchitectureMonitor.java | 5 +- .../DiskSpaceMonitorDescriptor.java | 5 +- .../node_monitors/ResponseTimeMonitor.java | 10 +- .../node_monitors/SwapSpaceMonitor.java | 6 +- .../node_monitors/TemporarySpaceMonitor.java | 4 +- .../hudson/os/solaris/ZFSProvisioner.java | 8 +- .../AbstractPasswordBasedSecurityRealm.java | 6 +- .../java/hudson/slaves/ChannelPinger.java | 6 +- .../slaves/ConnectionActivityMonitor.java | 7 +- .../java/hudson/slaves/SlaveComputer.java | 27 ++-- .../java/hudson/tasks/ArtifactArchiver.java | 3 +- .../main/java/hudson/tasks/Fingerprinter.java | 3 +- core/src/main/java/hudson/tasks/Maven.java | 3 +- core/src/main/java/hudson/tasks/Shell.java | 6 +- .../java/hudson/tasks/junit/JUnitParser.java | 5 +- .../test/DefaultTestResultParserImpl.java | 4 +- .../main/java/hudson/tools/JDKInstaller.java | 8 +- .../hudson/tools/ZipExtractionInstaller.java | 4 +- .../java/hudson/util/RemotingDiagnostics.java | 14 +- .../java/jenkins/security/MasterToSlave.java | 25 --- .../security/MasterToSlaveCallable.java | 11 +- .../NotReallyRoleSensitiveCallable.java | 21 +++ .../java/jenkins/security/SlaveToMaster.java | 26 ---- .../security/SlaveToMasterCallable.java | 11 +- .../jenkins/slaves/StandardOutputSwapper.java | 6 +- .../main/java/jenkins/util/VirtualFile.java | 6 +- core/src/test/java/hudson/LauncherTest.java | 4 +- core/src/test/java/hudson/os/SUTester.java | 3 +- .../java/hudson/util/ProcessTreeTest.java | 3 +- test/src/test/java/hudson/ProcTest.java | 5 +- .../logging/LogRecorderManagerTest.java | 3 +- .../java/hudson/slaves/JNLPLauncherTest.java | 6 +- .../security/DefaultFilePathFilterTest.java | 14 +- 44 files changed, 247 insertions(+), 251 deletions(-) delete mode 100644 core/src/main/java/jenkins/security/MasterToSlave.java create mode 100644 core/src/main/java/jenkins/security/NotReallyRoleSensitiveCallable.java delete mode 100644 core/src/main/java/jenkins/security/SlaveToMaster.java diff --git a/core/src/main/java/hudson/EnvVars.java b/core/src/main/java/hudson/EnvVars.java index b0a9962259..92d918077b 100644 --- a/core/src/main/java/hudson/EnvVars.java +++ b/core/src/main/java/hudson/EnvVars.java @@ -26,7 +26,7 @@ package hudson; import hudson.remoting.Callable; import hudson.remoting.VirtualChannel; import hudson.util.CaseInsensitiveComparator; -import jenkins.security.MasterToSlave; +import jenkins.security.MasterToSlaveCallable; import java.io.File; import java.io.IOException; @@ -213,8 +213,7 @@ public class EnvVars extends TreeMap { return channel.call(new GetEnvVars()); } - @MasterToSlave - private static final class GetEnvVars implements Callable { + private static final class GetEnvVars extends MasterToSlaveCallable { public EnvVars call() { return new EnvVars(EnvVars.masterEnvVars); } diff --git a/core/src/main/java/hudson/FilePath.java b/core/src/main/java/hudson/FilePath.java index 60f7b9ac4f..ed911a4a0a 100644 --- a/core/src/main/java/hudson/FilePath.java +++ b/core/src/main/java/hudson/FilePath.java @@ -55,9 +55,8 @@ import hudson.util.io.Archiver; import hudson.util.io.ArchiverFactory; import jenkins.FilePathFilter; import jenkins.model.Jenkins; -import jenkins.security.MasterToSlave; import jenkins.security.MasterToSlaveCallable; -import jenkins.security.SlaveToMaster; +import jenkins.security.Roles; import jenkins.util.VirtualFile; import org.apache.commons.fileupload.FileItem; import org.apache.commons.io.input.CountingInputStream; @@ -68,6 +67,8 @@ import org.apache.tools.ant.types.FileSet; import org.apache.tools.tar.TarEntry; import org.apache.tools.zip.ZipEntry; import org.apache.tools.zip.ZipFile; +import org.jenkinsci.remoting.Role; +import org.jenkinsci.remoting.RoleSensitive; import org.kohsuke.stapler.Stapler; import javax.annotation.Nonnull; @@ -94,6 +95,8 @@ import java.net.URL; import java.net.URLConnection; import java.util.ArrayList; import java.util.Arrays; +import java.util.Collection; +import java.util.Collections; import java.util.Comparator; import java.util.Enumeration; import java.util.List; @@ -432,7 +435,7 @@ public final class FilePath implements Serializable { */ public int archive(final ArchiverFactory factory, OutputStream os, final DirScanner scanner) throws IOException, InterruptedException { final OutputStream out = (channel!=null)?new RemoteOutputStream(os):os; - return act(new FileCallable() { + return act(new SecureFileCallable() { public Integer invoke(File f, VirtualChannel channel) throws IOException { Archiver a = factory.create(out); try { @@ -464,7 +467,7 @@ public final class FilePath implements Serializable { * @see #unzipFrom(InputStream) */ public void unzip(final FilePath target) throws IOException, InterruptedException { - target.act(new FileCallable() { + target.act(new SecureFileCallable() { public Void invoke(File dir, VirtualChannel channel) throws IOException, InterruptedException { if (FilePath.this.isRemote()) @@ -488,7 +491,7 @@ public final class FilePath implements Serializable { * @see #untarFrom(InputStream, TarCompression) */ public void untar(final FilePath target, final TarCompression compression) throws IOException, InterruptedException { - target.act(new FileCallable() { + target.act(new SecureFileCallable() { public Void invoke(File dir, VirtualChannel channel) throws IOException, InterruptedException { readFromTar(FilePath.this.getName(),dir,compression.extract(FilePath.this.read())); return null; @@ -507,7 +510,7 @@ public final class FilePath implements Serializable { */ public void unzipFrom(InputStream _in) throws IOException, InterruptedException { final InputStream in = new RemoteInputStream(_in); - act(new FileCallable() { + act(new SecureFileCallable() { public Void invoke(File dir, VirtualChannel channel) throws IOException { unzip(dir, in); return null; @@ -566,7 +569,7 @@ public final class FilePath implements Serializable { * Absolutizes this {@link FilePath} and returns the new one. */ public FilePath absolutize() throws IOException, InterruptedException { - return new FilePath(channel,act(new FileCallable() { + return new FilePath(channel,act(new SecureFileCallable() { private static final long serialVersionUID = 1L; public String invoke(File f, VirtualChannel channel) throws IOException { return f.getAbsolutePath(); @@ -584,7 +587,7 @@ public final class FilePath implements Serializable { * @since 1.456 */ public void symlinkTo(final String target, final TaskListener listener) throws IOException, InterruptedException { - act(new FileCallable() { + act(new SecureFileCallable() { private static final long serialVersionUID = 1L; public Void invoke(File f, VirtualChannel channel) throws IOException, InterruptedException { writing(f); @@ -602,7 +605,7 @@ public final class FilePath implements Serializable { * @since 1.456 */ public String readLink() throws IOException, InterruptedException { - return act(new FileCallable() { + return act(new SecureFileCallable() { private static final long serialVersionUID = 1L; public String invoke(File f, VirtualChannel channel) throws IOException, InterruptedException { return Util.resolveSymlink(reading(f)); @@ -676,7 +679,7 @@ public final class FilePath implements Serializable { public void untarFrom(InputStream _in, final TarCompression compression) throws IOException, InterruptedException { try { final InputStream in = new RemoteInputStream(_in); - act(new FileCallable() { + act(new SecureFileCallable() { public Void invoke(File dir, VirtualChannel channel) throws IOException { readFromTar("input stream",dir, compression.extract(in)); return null; @@ -786,8 +789,8 @@ public final class FilePath implements Serializable { } } - @MasterToSlave // this reads from arbitrary URL - private final class Unpack implements FileCallable { + // this reads from arbitrary URL + private final class Unpack extends MasterToSlaveFileCallable { private final URL archive; Unpack(URL archive) { this.archive = archive; @@ -881,9 +884,14 @@ public final class FilePath implements Serializable { * Code that gets executed on the machine where the {@link FilePath} is local. * Used to act on {@link FilePath}. * Warning: implementations must be serializable, so prefer a static nested class to an inner class. + * + *

+ * Subtypes would likely want to extend from either {@link MasterToSlaveCallable} + * or {@link SlaveToMasterFileCallable}. + * * @see FilePath#act(FileCallable) */ - public interface FileCallable extends Serializable { + public interface FileCallable extends Serializable, RoleSensitive { /** * Performs the computational task on the node where the data is located. * @@ -899,6 +907,37 @@ public final class FilePath implements Serializable { T invoke(File f, VirtualChannel channel) throws IOException, InterruptedException; } + /** + * {@link FileCallable}s that are meant to be only used on the master. + */ + public static abstract class MasterToSlaveFileCallable implements FileCallable { + @Override + public Collection getRecipients() { + return Roles.FOR_SLAVE; + } + private static final long serialVersionUID = 1L; + } + + /** + * {@link FileCallable}s that can be executed on the master, sent by the slave. + */ + public static abstract class SlaveToMasterFileCallable implements FileCallable { + @Override + public Collection getRecipients() { + return Roles.FOR_MASTER; + } + private static final long serialVersionUID = 1L; + } + + /** + * {@link FileCallable}s that can be executed anywhere, including the master. + * + * The code is the same as {@link SlaveToMasterFileCallable}, but used as a marker to + * designate those impls that use {@link FilePathFilter}. + */ + /*package*/ static abstract class SecureFileCallable extends SlaveToMasterFileCallable { + } + /** * Executes some program on the machine that this {@link FilePath} exists, * so that one can perform local file operations. @@ -1044,6 +1083,12 @@ public final class FilePath implements Serializable { throw (IOException)new InterruptedIOException().initCause(e); } } + + @Override + public Collection getRecipients() { + return task.getRecipients(); + } + private static final long serialVersionUID = 1L; }; } @@ -1053,7 +1098,7 @@ public final class FilePath implements Serializable { * on which this file is available. */ public URI toURI() throws IOException, InterruptedException { - return act(new FileCallable() { + return act(new SecureFileCallable() { private static final long serialVersionUID = 1L; public URI invoke(File f, VirtualChannel channel) { return f.toURI(); @@ -1074,7 +1119,7 @@ public final class FilePath implements Serializable { * Creates this directory. */ public void mkdirs() throws IOException, InterruptedException { - if(!act(new FileCallable() { + if(!act(new SecureFileCallable() { private static final long serialVersionUID = 1L; public Boolean invoke(File f, VirtualChannel channel) throws IOException, InterruptedException { if(mkdirs(f) || f.exists()) @@ -1093,7 +1138,7 @@ public final class FilePath implements Serializable { * Deletes this directory, including all its contents recursively. */ public void deleteRecursive() throws IOException, InterruptedException { - act(new FileCallable() { + act(new SecureFileCallable() { private static final long serialVersionUID = 1L; public Void invoke(File f, VirtualChannel channel) throws IOException { deleteRecursive(deleting(f)); @@ -1106,7 +1151,7 @@ public final class FilePath implements Serializable { * Deletes all the contents of this directory, but not the directory itself */ public void deleteContents() throws IOException, InterruptedException { - act(new FileCallable() { + act(new SecureFileCallable() { private static final long serialVersionUID = 1L; public Void invoke(File f, VirtualChannel channel) throws IOException { deleteContentsRecursive(f); @@ -1223,7 +1268,7 @@ public final class FilePath implements Serializable { */ public FilePath createTempFile(final String prefix, final String suffix) throws IOException, InterruptedException { try { - return new FilePath(this,act(new FileCallable() { + return new FilePath(this,act(new SecureFileCallable() { private static final long serialVersionUID = 1L; public String invoke(File dir, VirtualChannel channel) throws IOException { File f = writing(File.createTempFile(prefix, suffix, dir)); @@ -1279,7 +1324,7 @@ public final class FilePath implements Serializable { */ public FilePath createTextTempFile(final String prefix, final String suffix, final String contents, final boolean inThisDirectory) throws IOException, InterruptedException { try { - return new FilePath(channel,act(new FileCallable() { + return new FilePath(channel,act(new SecureFileCallable() { private static final long serialVersionUID = 1L; public String invoke(File dir, VirtualChannel channel) throws IOException { if(!inThisDirectory) @@ -1325,7 +1370,7 @@ public final class FilePath implements Serializable { */ public FilePath createTempDir(final String prefix, final String suffix) throws IOException, InterruptedException { try { - return new FilePath(this,act(new FileCallable() { + return new FilePath(this,act(new SecureFileCallable() { private static final long serialVersionUID = 1L; public String invoke(File dir, VirtualChannel channel) throws IOException { File f = File.createTempFile(prefix, suffix, dir); @@ -1345,7 +1390,7 @@ public final class FilePath implements Serializable { * @return true, for a modicum of compatibility */ public boolean delete() throws IOException, InterruptedException { - act(new FileCallable() { + act(new SecureFileCallable() { private static final long serialVersionUID = 1L; public Void invoke(File f, VirtualChannel channel) throws IOException { Util.deleteFile(deleting(f)); @@ -1359,7 +1404,7 @@ public final class FilePath implements Serializable { * Checks if the file exists. */ public boolean exists() throws IOException, InterruptedException { - return act(new FileCallable() { + return act(new SecureFileCallable() { private static final long serialVersionUID = 1L; public Boolean invoke(File f, VirtualChannel channel) throws IOException { return stating(f).exists(); @@ -1375,7 +1420,7 @@ public final class FilePath implements Serializable { * @see #touch(long) */ public long lastModified() throws IOException, InterruptedException { - return act(new FileCallable() { + return act(new SecureFileCallable() { private static final long serialVersionUID = 1L; public Long invoke(File f, VirtualChannel channel) throws IOException { return stating(f).lastModified(); @@ -1389,7 +1434,7 @@ public final class FilePath implements Serializable { * @since 1.299 */ public void touch(final long timestamp) throws IOException, InterruptedException { - act(new FileCallable() { + act(new SecureFileCallable() { private static final long serialVersionUID = -5094638816500738429L; public Void invoke(File f, VirtualChannel channel) throws IOException { if(!f.exists()) @@ -1402,7 +1447,7 @@ public final class FilePath implements Serializable { } private void setLastModifiedIfPossible(final long timestamp) throws IOException, InterruptedException { - String message = act(new FileCallable() { + String message = act(new SecureFileCallable() { private static final long serialVersionUID = -828220335793641630L; public String invoke(File f, VirtualChannel channel) throws IOException { if(!writing(f).setLastModified(timestamp)) { @@ -1427,7 +1472,7 @@ public final class FilePath implements Serializable { * Checks if the file is a directory. */ public boolean isDirectory() throws IOException, InterruptedException { - return act(new FileCallable() { + return act(new SecureFileCallable() { private static final long serialVersionUID = 1L; public Boolean invoke(File f, VirtualChannel channel) throws IOException { return stating(f).isDirectory(); @@ -1441,7 +1486,7 @@ public final class FilePath implements Serializable { * @since 1.129 */ public long length() throws IOException, InterruptedException { - return act(new FileCallable() { + return act(new SecureFileCallable() { private static final long serialVersionUID = 1L; public Long invoke(File f, VirtualChannel channel) throws IOException { return stating(f).length(); @@ -1466,7 +1511,7 @@ public final class FilePath implements Serializable { */ public void chmod(final int mask) throws IOException, InterruptedException { if(!isUnix() || mask==-1) return; - act(new FileCallable() { + act(new SecureFileCallable() { private static final long serialVersionUID = 1L; public Void invoke(File f, VirtualChannel channel) throws IOException { _chmod(writing(f), mask); @@ -1517,7 +1562,7 @@ public final class FilePath implements Serializable { */ public int mode() throws IOException, InterruptedException, PosixException { if(!isUnix()) return -1; - return act(new FileCallable() { + return act(new SecureFileCallable() { private static final long serialVersionUID = 1L; public Integer invoke(File f, VirtualChannel channel) throws IOException { return IOUtils.mode(stating(f)); @@ -1564,7 +1609,7 @@ public final class FilePath implements Serializable { if (filter != null && !(filter instanceof Serializable)) { throw new IllegalArgumentException("Non-serializable filter of " + filter.getClass()); } - return act(new FileCallable>() { + return act(new SecureFileCallable>() { private static final long serialVersionUID = 1L; public List invoke(File f, VirtualChannel channel) throws IOException { File[] children = reading(f).listFiles(filter); @@ -1617,7 +1662,7 @@ public final class FilePath implements Serializable { * @since 1.465 */ public FilePath[] list(final String includes, final String excludes, final boolean defaultExcludes) throws IOException, InterruptedException { - return act(new FileCallable() { + return act(new SecureFileCallable() { private static final long serialVersionUID = 1L; public FilePath[] invoke(File f, VirtualChannel channel) throws IOException { String[] files = glob(reading(f), includes, excludes, defaultExcludes); @@ -1655,7 +1700,7 @@ public final class FilePath implements Serializable { return new FileInputStream(reading(new File(remote))); final Pipe p = Pipe.createRemoteToLocal(); - actAsync(new FileCallable() { + actAsync(new SecureFileCallable() { private static final long serialVersionUID = 1L; @Override @@ -1709,7 +1754,7 @@ public final class FilePath implements Serializable { return new FileOutputStream(writing(f)); } - return act(new FileCallable() { + return act(new SecureFileCallable() { private static final long serialVersionUID = 1L; public OutputStream invoke(File f, VirtualChannel channel) throws IOException, InterruptedException { f = f.getAbsoluteFile(); @@ -1728,7 +1773,7 @@ public final class FilePath implements Serializable { * @since 1.105 */ public void write(final String content, final String encoding) throws IOException, InterruptedException { - act(new FileCallable() { + act(new SecureFileCallable() { private static final long serialVersionUID = 1L; public Void invoke(File f, VirtualChannel channel) throws IOException { mkdirs(f.getParentFile()); @@ -1749,7 +1794,7 @@ public final class FilePath implements Serializable { * @see Util#getDigestOf(File) */ public String digest() throws IOException, InterruptedException { - return act(new FileCallable() { + return act(new SecureFileCallable() { private static final long serialVersionUID = 1L; public String invoke(File f, VirtualChannel channel) throws IOException { return Util.getDigestOf(reading(f)); @@ -1765,7 +1810,7 @@ public final class FilePath implements Serializable { if(this.channel != target.channel) { throw new IOException("renameTo target must be on the same host"); } - act(new FileCallable() { + act(new SecureFileCallable() { private static final long serialVersionUID = 1L; public Void invoke(File f, VirtualChannel channel) throws IOException { reading(f).renameTo(creating(new File(target.remote))); @@ -1783,7 +1828,7 @@ public final class FilePath implements Serializable { if(this.channel != target.channel) { throw new IOException("pullUpTo target must be on the same host"); } - act(new FileCallable() { + act(new SecureFileCallable() { private static final long serialVersionUID = 1L; public Void invoke(File f, VirtualChannel channel) throws IOException { File t = new File(target.getRemote()); @@ -1832,7 +1877,7 @@ public final class FilePath implements Serializable { public void copyTo(OutputStream os) throws IOException, InterruptedException { final OutputStream out = new RemoteOutputStream(os); - act(new FileCallable() { + act(new SecureFileCallable() { private static final long serialVersionUID = 4088559042349254141L; public Void invoke(File f, VirtualChannel channel) throws IOException { FileInputStream fis = null; @@ -1933,7 +1978,7 @@ public final class FilePath implements Serializable { public int copyRecursiveTo(final DirScanner scanner, final FilePath target, final String description) throws IOException, InterruptedException { if(this.channel==target.channel) { // local to local copy. - return act(new FileCallable() { + return act(new SecureFileCallable() { private static final long serialVersionUID = 1L; public Integer invoke(File base, VirtualChannel channel) throws IOException { if(!base.exists()) return 0; @@ -1975,7 +2020,7 @@ public final class FilePath implements Serializable { // local -> remote copy final Pipe pipe = Pipe.createLocalToRemote(); - Future future = target.actAsync(new FileCallable() { + Future future = target.actAsync(new SecureFileCallable() { private static final long serialVersionUID = 1L; public Void invoke(File f, VirtualChannel channel) throws IOException { try { @@ -1986,7 +2031,7 @@ public final class FilePath implements Serializable { } } }); - Future future2 = actAsync(new FileCallable() { + Future future2 = actAsync(new SecureFileCallable() { private static final long serialVersionUID = 1L; @Override public Integer invoke(File f, VirtualChannel channel) throws IOException, InterruptedException { return writeToTar(new File(remote), scanner, TarCompression.GZIP.compress(pipe.getOut())); @@ -2003,7 +2048,7 @@ public final class FilePath implements Serializable { // remote -> local copy final Pipe pipe = Pipe.createRemoteToLocal(); - Future future = actAsync(new FileCallable() { + Future future = actAsync(new SecureFileCallable() { private static final long serialVersionUID = 1L; public Integer invoke(File f, VirtualChannel channel) throws IOException { try { @@ -2126,8 +2171,7 @@ public final class FilePath implements Serializable { return new RemoteLauncher(listener,channel,channel.call(new IsUnix())); } - @MasterToSlave @SlaveToMaster - private static final class IsUnix implements Callable { + private static final class IsUnix extends MasterToSlaveCallable { public Boolean call() throws IOException { return File.pathSeparatorChar==':'; } @@ -2164,7 +2208,7 @@ public final class FilePath implements Serializable { * @since 1.484 */ public String validateAntFileMask(final String fileMasks, final int bound) throws IOException, InterruptedException { - return act(new FileCallable() { + return act(new MasterToSlaveFileCallable() { private static final long serialVersionUID = 1; public String invoke(File dir, VirtualChannel channel) throws IOException, InterruptedException { if(fileMasks.startsWith("~")) @@ -2467,8 +2511,6 @@ public final class FilePath implements Serializable { /** * Adapts {@link FileCallable} to {@link Callable}. */ - @MasterToSlave // the normal case - @SlaveToMaster // possible, but triggers FilePathFilter private class FileCallableWrapper implements DelegatingCallable { private final FileCallable callable; private transient ClassLoader classLoader; @@ -2491,6 +2533,14 @@ public final class FilePath implements Serializable { } } + /** + * Role check comes from {@link FileCallable}s. + */ + @Override + public Collection getRecipients() { + return callable.getRecipients(); + } + public ClassLoader getClassLoader() { return classLoader; } diff --git a/core/src/main/java/hudson/Launcher.java b/core/src/main/java/hudson/Launcher.java index 6f1b4b2205..3e56ed2991 100644 --- a/core/src/main/java/hudson/Launcher.java +++ b/core/src/main/java/hudson/Launcher.java @@ -38,7 +38,7 @@ import hudson.remoting.VirtualChannel; import hudson.util.StreamCopyThread; import hudson.util.ArgumentListBuilder; import hudson.util.ProcessTree; -import jenkins.security.MasterToSlave; +import jenkins.security.MasterToSlaveCallable; import org.apache.commons.io.input.NullInputStream; import java.io.BufferedOutputStream; @@ -888,8 +888,7 @@ public abstract class Launcher { getChannel().call(new KillTask(modelEnvVars)); } - @MasterToSlave - private static final class KillTask implements Callable { + private static final class KillTask extends MasterToSlaveCallable { private final Map modelEnvVars; public KillTask(Map modelEnvVars) { @@ -964,8 +963,7 @@ public abstract class Launcher { IOTriplet getIOtriplet(); } - @MasterToSlave - private static class RemoteLaunchCallable implements Callable { + private static class RemoteLaunchCallable extends MasterToSlaveCallable { private final List cmd; private final boolean[] masks; private final String[] env; @@ -1035,8 +1033,7 @@ public abstract class Launcher { private static final long serialVersionUID = 1L; } - @MasterToSlave - private static class RemoteChannelLaunchCallable implements Callable { + private static class RemoteChannelLaunchCallable extends MasterToSlaveCallable { private final String[] cmd; private final Pipe out; private final String workDir; diff --git a/core/src/main/java/hudson/cli/CLICommand.java b/core/src/main/java/hudson/cli/CLICommand.java index 0efb64f3f9..aa41dbf425 100644 --- a/core/src/main/java/hudson/cli/CLICommand.java +++ b/core/src/main/java/hudson/cli/CLICommand.java @@ -36,8 +36,7 @@ import hudson.remoting.Channel; import hudson.remoting.ChannelProperty; import hudson.security.CliAuthenticator; import hudson.security.SecurityRealm; -import jenkins.security.MasterToSlave; -import jenkins.security.SlaveToMaster; +import jenkins.security.MasterToSlaveCallable; import org.acegisecurity.Authentication; import org.acegisecurity.BadCredentialsException; import org.acegisecurity.context.SecurityContext; @@ -361,8 +360,7 @@ public abstract class CLICommand implements ExtensionPoint, Cloneable { return checkChannel().call(new GetSystemProperty(name)); } - @MasterToSlave - private static final class GetSystemProperty implements Callable { + private static final class GetSystemProperty extends MasterToSlaveCallable { private final String name; private GetSystemProperty(String name) { @@ -391,8 +389,7 @@ public abstract class CLICommand implements ExtensionPoint, Cloneable { } } - @MasterToSlave @SlaveToMaster - private static final class GetCharset implements Callable { + private static final class GetCharset extends MasterToSlaveCallable { public String call() throws IOException { return Charset.defaultCharset().name(); } @@ -407,8 +404,7 @@ public abstract class CLICommand implements ExtensionPoint, Cloneable { return checkChannel().call(new GetEnvironmentVariable(name)); } - @MasterToSlave - private static final class GetEnvironmentVariable implements Callable { + private static final class GetEnvironmentVariable extends MasterToSlaveCallable { private final String name; private GetEnvironmentVariable(String name) { diff --git a/core/src/main/java/hudson/cli/CommandDuringBuild.java b/core/src/main/java/hudson/cli/CommandDuringBuild.java index 759563744a..1ebaad75a3 100644 --- a/core/src/main/java/hudson/cli/CommandDuringBuild.java +++ b/core/src/main/java/hudson/cli/CommandDuringBuild.java @@ -28,7 +28,7 @@ import jenkins.model.Jenkins; import hudson.model.Job; import hudson.model.Run; import hudson.remoting.Callable; -import jenkins.security.MasterToSlave; +import jenkins.security.MasterToSlaveCallable; import org.kohsuke.args4j.CmdLineException; import java.io.IOException; @@ -82,8 +82,7 @@ public abstract class CommandDuringBuild extends CLICommand { /** * Gets the environment variables that points to the build being executed. */ - @MasterToSlave - private static final class GetCharacteristicEnvironmentVariables implements Callable { + private static final class GetCharacteristicEnvironmentVariables extends MasterToSlaveCallable { public String[] call() throws IOException { return new String[] { System.getenv("JOB_NAME"), diff --git a/core/src/main/java/hudson/cli/InstallToolCommand.java b/core/src/main/java/hudson/cli/InstallToolCommand.java index e39d90fba4..a5dd319335 100644 --- a/core/src/main/java/hudson/cli/InstallToolCommand.java +++ b/core/src/main/java/hudson/cli/InstallToolCommand.java @@ -31,10 +31,7 @@ import hudson.model.AbstractProject; import hudson.model.Run; import hudson.model.Executor; import hudson.model.Node; -import hudson.model.EnvironmentSpecific; import hudson.model.Item; -import hudson.remoting.Callable; -import hudson.slaves.NodeSpecific; import hudson.util.EditDistance; import hudson.util.StreamTaskListener; import hudson.tools.ToolDescriptor; @@ -44,7 +41,7 @@ import java.util.List; import java.util.ArrayList; import java.io.IOException; -import jenkins.security.MasterToSlave; +import jenkins.security.MasterToSlaveCallable; import org.kohsuke.args4j.Argument; /** @@ -129,8 +126,7 @@ public class InstallToolCommand extends CLICommand { return 0; } - @MasterToSlave - private static final class BuildIDs implements Callable { + private static final class BuildIDs extends MasterToSlaveCallable { String job,number,id; public BuildIDs call() throws IOException { diff --git a/core/src/main/java/hudson/cli/util/ScriptLoader.java b/core/src/main/java/hudson/cli/util/ScriptLoader.java index 5b590ac313..e2252efbd5 100644 --- a/core/src/main/java/hudson/cli/util/ScriptLoader.java +++ b/core/src/main/java/hudson/cli/util/ScriptLoader.java @@ -1,8 +1,7 @@ package hudson.cli.util; import hudson.AbortException; -import hudson.remoting.Callable; -import jenkins.security.MasterToSlave; +import jenkins.security.MasterToSlaveCallable; import org.apache.commons.io.FileUtils; import org.apache.commons.io.IOUtils; @@ -17,8 +16,7 @@ import java.net.URL; * * @author vjuranek */ -@MasterToSlave -public class ScriptLoader implements Callable { +public class ScriptLoader extends MasterToSlaveCallable { private final String script; diff --git a/core/src/main/java/hudson/logging/LogRecorder.java b/core/src/main/java/hudson/logging/LogRecorder.java index 9cc456f9f4..dae28a2c53 100644 --- a/core/src/main/java/hudson/logging/LogRecorder.java +++ b/core/src/main/java/hudson/logging/LogRecorder.java @@ -42,7 +42,7 @@ import hudson.slaves.ComputerListener; import hudson.util.CopyOnWriteList; import hudson.util.RingBufferLogHandler; import hudson.util.XStream2; -import jenkins.security.MasterToSlave; +import jenkins.security.MasterToSlaveCallable; import net.sf.json.JSONObject; import org.kohsuke.stapler.DataBoundConstructor; import org.kohsuke.stapler.StaplerRequest; @@ -161,8 +161,7 @@ public class LogRecorder extends AbstractModelObject implements Saveable { } - @MasterToSlave - private static final class SetLevel implements Callable { + private static final class SetLevel extends MasterToSlaveCallable { /** known loggers (kept per slave), to avoid GC */ @SuppressWarnings("MismatchedQueryAndUpdateOfCollection") private static final Set loggers = new HashSet(); private final String name; diff --git a/core/src/main/java/hudson/model/AbstractItem.java b/core/src/main/java/hudson/model/AbstractItem.java index 15de44afa6..cd9afb1331 100644 --- a/core/src/main/java/hudson/model/AbstractItem.java +++ b/core/src/main/java/hudson/model/AbstractItem.java @@ -34,7 +34,6 @@ import hudson.cli.declarative.CLIMethod; import hudson.cli.declarative.CLIResolver; import hudson.model.listeners.ItemListener; import hudson.model.listeners.SaveableListener; -import hudson.remoting.Callable; import hudson.security.AccessControlled; import hudson.security.Permission; import hudson.security.ACL; @@ -44,6 +43,7 @@ import hudson.util.AtomicFileWriter; import hudson.util.IOException2; import hudson.util.IOUtils; import jenkins.model.Jenkins; +import jenkins.security.NotReallyRoleSensitiveCallable; import org.acegisecurity.Authentication; import org.apache.tools.ant.taskdefs.Copy; import org.apache.tools.ant.types.FileSet; @@ -216,7 +216,7 @@ public abstract class AbstractItem extends Actionable implements Item, HttpDelet // the test to see if the project already exists or not needs to be done in escalated privilege // to avoid overwriting - ACL.impersonate(ACL.SYSTEM,new Callable() { + ACL.impersonate(ACL.SYSTEM,new NotReallyRoleSensitiveCallable() { final Authentication user = Jenkins.getAuthentication(); @Override public Void call() throws IOException { diff --git a/core/src/main/java/hudson/model/Computer.java b/core/src/main/java/hudson/model/Computer.java index 42c2c76b89..5d1a60f075 100644 --- a/core/src/main/java/hudson/model/Computer.java +++ b/core/src/main/java/hudson/model/Computer.java @@ -58,7 +58,7 @@ import hudson.util.RemotingDiagnostics.HeapDump; import hudson.util.RunList; import hudson.util.Futures; import jenkins.model.Jenkins; -import jenkins.security.MasterToSlave; +import jenkins.security.MasterToSlaveCallable; import org.kohsuke.args4j.Argument; import org.kohsuke.args4j.CmdLineException; import org.kohsuke.stapler.StaplerRequest; @@ -1025,8 +1025,7 @@ public /*transient*/ abstract class Computer extends Actionable implements Acces oneOffExecutors.remove(e); } - @MasterToSlave - private static class ListPossibleNames implements Callable,IOException> { + private static class ListPossibleNames extends MasterToSlaveCallable,IOException> { public List call() throws IOException { List names = new ArrayList(); @@ -1056,8 +1055,7 @@ public /*transient*/ abstract class Computer extends Actionable implements Acces private static final long serialVersionUID = 1L; } - @MasterToSlave - private static class GetFallbackName implements Callable { + private static class GetFallbackName extends MasterToSlaveCallable { public String call() throws IOException { return System.getProperty("host.name"); } @@ -1146,8 +1144,7 @@ public /*transient*/ abstract class Computer extends Actionable implements Acces w.close(); } - @MasterToSlave - private static final class DumpExportTableTask implements Callable { + private static final class DumpExportTableTask extends MasterToSlaveCallable { public String call() throws IOException { StringWriter sw = new StringWriter(); PrintWriter pw = new PrintWriter(sw); diff --git a/core/src/main/java/hudson/model/Slave.java b/core/src/main/java/hudson/model/Slave.java index 53d429379b..20a494bc49 100644 --- a/core/src/main/java/hudson/model/Slave.java +++ b/core/src/main/java/hudson/model/Slave.java @@ -58,7 +58,7 @@ import javax.servlet.ServletException; import hudson.util.TimeUnit2; import jenkins.model.Jenkins; -import jenkins.security.MasterToSlave; +import jenkins.security.MasterToSlaveCallable; import jenkins.slaves.WorkspaceLocator; import org.apache.commons.io.IOUtils; @@ -439,8 +439,7 @@ public abstract class Slave extends Node implements Serializable { *

  • When it's read on this side as a return value, it morphs itself into {@link ClockDifference}. * */ - @MasterToSlave - private static final class GetClockDifference1 implements Callable { + private static final class GetClockDifference1 extends MasterToSlaveCallable { public ClockDifference call() { // this method must be being invoked locally, which means the clock is in sync return new ClockDifference(0); @@ -453,8 +452,7 @@ public abstract class Slave extends Node implements Serializable { private static final long serialVersionUID = 1L; } - @MasterToSlave - private static final class GetClockDifference2 implements Callable { + private static final class GetClockDifference2 extends MasterToSlaveCallable { /** * Capture the time on the master when this object is sent to remote, which is when * {@link GetClockDifference1#writeReplace()} is run. @@ -468,7 +466,6 @@ public abstract class Slave extends Node implements Serializable { private static final long serialVersionUID = 1L; } - @MasterToSlave private static final class GetClockDifference3 implements Serializable { private final long remoteTime = System.currentTimeMillis(); private final long startTime; diff --git a/core/src/main/java/hudson/node_monitors/ArchitectureMonitor.java b/core/src/main/java/hudson/node_monitors/ArchitectureMonitor.java index 05c59a91dd..ec0618f807 100644 --- a/core/src/main/java/hudson/node_monitors/ArchitectureMonitor.java +++ b/core/src/main/java/hudson/node_monitors/ArchitectureMonitor.java @@ -26,7 +26,7 @@ package hudson.node_monitors; import hudson.model.Computer; import hudson.remoting.Callable; import hudson.Extension; -import jenkins.security.MasterToSlave; +import jenkins.security.MasterToSlaveCallable; import net.sf.json.JSONObject; import org.kohsuke.stapler.StaplerRequest; @@ -57,8 +57,7 @@ public class ArchitectureMonitor extends NodeMonitor { /** * Obtains the string that represents the architecture. */ - @MasterToSlave - private static class GetArchTask implements Callable { + private static class GetArchTask extends MasterToSlaveCallable { public String call() { String os = System.getProperty("os.name"); String arch = System.getProperty("os.arch"); diff --git a/core/src/main/java/hudson/node_monitors/DiskSpaceMonitorDescriptor.java b/core/src/main/java/hudson/node_monitors/DiskSpaceMonitorDescriptor.java index 8f1fb84995..4d53f720b5 100644 --- a/core/src/main/java/hudson/node_monitors/DiskSpaceMonitorDescriptor.java +++ b/core/src/main/java/hudson/node_monitors/DiskSpaceMonitorDescriptor.java @@ -23,8 +23,7 @@ */ package hudson.node_monitors; -import hudson.FilePath.FileCallable; -import hudson.model.Computer; +import hudson.FilePath.MasterToSlaveFileCallable; import hudson.remoting.VirtualChannel; import hudson.Util; import hudson.slaves.OfflineCause; @@ -159,7 +158,7 @@ public abstract class DiskSpaceMonitorDescriptor extends AbstractAsyncNodeMonito private static final long serialVersionUID = 2L; } - protected static final class GetUsableSpace implements FileCallable { + protected static final class GetUsableSpace extends MasterToSlaveFileCallable { public GetUsableSpace() {} @IgnoreJRERequirement public DiskSpace invoke(File f, VirtualChannel channel) throws IOException { diff --git a/core/src/main/java/hudson/node_monitors/ResponseTimeMonitor.java b/core/src/main/java/hudson/node_monitors/ResponseTimeMonitor.java index 491b991e7a..85784327a2 100644 --- a/core/src/main/java/hudson/node_monitors/ResponseTimeMonitor.java +++ b/core/src/main/java/hudson/node_monitors/ResponseTimeMonitor.java @@ -32,8 +32,7 @@ import hudson.remoting.Future; import hudson.util.ClockDifference; import hudson.util.TimeUnit2; import hudson.util.IOException2; -import jenkins.security.MasterToSlave; -import jenkins.security.SlaveToMaster; +import jenkins.security.MasterToSlaveCallable; import net.sf.json.JSONObject; import org.kohsuke.stapler.StaplerRequest; @@ -94,8 +93,7 @@ public class ResponseTimeMonitor extends NodeMonitor { } }; - @MasterToSlave - private static final class Step1 implements Callable { + private static final class Step1 extends MasterToSlaveCallable { private Data cur; private Step1(Data cur) { @@ -114,8 +112,7 @@ public class ResponseTimeMonitor extends NodeMonitor { private static final long serialVersionUID = 1L; } - @MasterToSlave - private static final class Step2 implements Callable { + private static final class Step2 extends MasterToSlaveCallable { private final Data cur; private final long start = System.currentTimeMillis(); @@ -131,7 +128,6 @@ public class ResponseTimeMonitor extends NodeMonitor { private static final long serialVersionUID = 1L; } - @SlaveToMaster private static final class Step3 implements Serializable { private final Data cur; private final long start; diff --git a/core/src/main/java/hudson/node_monitors/SwapSpaceMonitor.java b/core/src/main/java/hudson/node_monitors/SwapSpaceMonitor.java index a72b94e84d..5efcc974bc 100644 --- a/core/src/main/java/hudson/node_monitors/SwapSpaceMonitor.java +++ b/core/src/main/java/hudson/node_monitors/SwapSpaceMonitor.java @@ -27,8 +27,7 @@ import hudson.Util; import hudson.Extension; import hudson.model.Computer; import jenkins.model.Jenkins; -import hudson.remoting.Callable; -import jenkins.security.MasterToSlave; +import jenkins.security.MasterToSlaveCallable; import net.sf.json.JSONObject; import org.jvnet.hudson.MemoryMonitor; import org.jvnet.hudson.MemoryUsage; @@ -98,8 +97,7 @@ public class SwapSpaceMonitor extends NodeMonitor { /** * Obtains the string that represents the architecture. */ - @MasterToSlave - private static class MonitorTask implements Callable { + private static class MonitorTask extends MasterToSlaveCallable { public MemoryUsage call() throws IOException { MemoryMonitor mm; try { diff --git a/core/src/main/java/hudson/node_monitors/TemporarySpaceMonitor.java b/core/src/main/java/hudson/node_monitors/TemporarySpaceMonitor.java index 05407d318f..707c043c5f 100644 --- a/core/src/main/java/hudson/node_monitors/TemporarySpaceMonitor.java +++ b/core/src/main/java/hudson/node_monitors/TemporarySpaceMonitor.java @@ -25,7 +25,7 @@ package hudson.node_monitors; import hudson.Extension; import hudson.FilePath; -import hudson.FilePath.FileCallable; +import hudson.FilePath.MasterToSlaveFileCallable; import hudson.Functions; import hudson.model.Computer; import hudson.remoting.Callable; @@ -82,7 +82,7 @@ public class TemporarySpaceMonitor extends AbstractDiskSpaceMonitor { return null; } - protected static final class GetTempSpace implements FileCallable { + protected static final class GetTempSpace extends MasterToSlaveFileCallable { @IgnoreJRERequirement public DiskSpace invoke(File f, VirtualChannel channel) throws IOException { try { diff --git a/core/src/main/java/hudson/os/solaris/ZFSProvisioner.java b/core/src/main/java/hudson/os/solaris/ZFSProvisioner.java index 3cae513ffa..b2f5a4443a 100644 --- a/core/src/main/java/hudson/os/solaris/ZFSProvisioner.java +++ b/core/src/main/java/hudson/os/solaris/ZFSProvisioner.java @@ -23,13 +23,13 @@ */ package hudson.os.solaris; +import hudson.FilePath.MasterToSlaveFileCallable; import hudson.FileSystemProvisioner; import hudson.FilePath; import hudson.WorkspaceSnapshot; import hudson.FileSystemProvisionerDescriptor; import hudson.Extension; import hudson.remoting.VirtualChannel; -import hudson.FilePath.FileCallable; import hudson.model.AbstractBuild; import hudson.model.TaskListener; import hudson.model.AbstractProject; @@ -52,7 +52,7 @@ public class ZFSProvisioner extends FileSystemProvisioner implements Serializabl private final String rootDataset; public ZFSProvisioner(Node node) throws IOException, InterruptedException { - rootDataset = node.getRootPath().act(new FileCallable() { + rootDataset = node.getRootPath().act(new MasterToSlaveFileCallable() { private static final long serialVersionUID = -2142349338699797436L; public String invoke(File f, VirtualChannel channel) throws IOException { @@ -68,7 +68,7 @@ public class ZFSProvisioner extends FileSystemProvisioner implements Serializabl public void prepareWorkspace(AbstractBuild build, FilePath ws, final TaskListener listener) throws IOException, InterruptedException { final String name = build.getProject().getFullName(); - ws.act(new FileCallable() { + ws.act(new MasterToSlaveFileCallable() { private static final long serialVersionUID = 2129531727963121198L; public Void invoke(File f, VirtualChannel channel) throws IOException { @@ -87,7 +87,7 @@ public class ZFSProvisioner extends FileSystemProvisioner implements Serializabl } public void discardWorkspace(AbstractProject project, FilePath ws) throws IOException, InterruptedException { - ws.act(new FileCallable() { + ws.act(new MasterToSlaveFileCallable() { private static final long serialVersionUID = 1916618107019257530L; public Void invoke(File f, VirtualChannel channel) throws IOException { diff --git a/core/src/main/java/hudson/security/AbstractPasswordBasedSecurityRealm.java b/core/src/main/java/hudson/security/AbstractPasswordBasedSecurityRealm.java index 84e9b163d6..eeff6baa95 100644 --- a/core/src/main/java/hudson/security/AbstractPasswordBasedSecurityRealm.java +++ b/core/src/main/java/hudson/security/AbstractPasswordBasedSecurityRealm.java @@ -4,9 +4,8 @@ import groovy.lang.Binding; import hudson.FilePath; import hudson.cli.CLICommand; import jenkins.model.Jenkins; -import hudson.remoting.Callable; import hudson.util.spring.BeanBuilder; -import jenkins.security.MasterToSlave; +import jenkins.security.MasterToSlaveCallable; import org.acegisecurity.Authentication; import org.acegisecurity.AuthenticationException; import org.acegisecurity.AuthenticationManager; @@ -141,8 +140,7 @@ public abstract class AbstractPasswordBasedSecurityRealm extends SecurityRealm i /** * Asks for the password. */ - @MasterToSlave - private static class InteractivelyAskForPassword implements Callable { + private static class InteractivelyAskForPassword extends MasterToSlaveCallable { @IgnoreJRERequirement public String call() throws IOException { Console console = System.console(); diff --git a/core/src/main/java/hudson/slaves/ChannelPinger.java b/core/src/main/java/hudson/slaves/ChannelPinger.java index f7de0f0349..bf3b4d3034 100644 --- a/core/src/main/java/hudson/slaves/ChannelPinger.java +++ b/core/src/main/java/hudson/slaves/ChannelPinger.java @@ -28,10 +28,9 @@ import hudson.FilePath; import hudson.model.Computer; import hudson.model.Slave; import hudson.model.TaskListener; -import hudson.remoting.Callable; import hudson.remoting.Channel; import hudson.remoting.PingThread; -import jenkins.security.MasterToSlave; +import jenkins.security.MasterToSlaveCallable; import java.io.IOException; import java.util.concurrent.atomic.AtomicBoolean; @@ -86,8 +85,7 @@ public class ChannelPinger extends ComputerListener { setUpPingForChannel(channel, pingInterval); } - @MasterToSlave - private static class SetUpRemotePing implements Callable { + private static class SetUpRemotePing extends MasterToSlaveCallable { private static final long serialVersionUID = -2702219700841759872L; private int pingInterval; public SetUpRemotePing(int pingInterval) { diff --git a/core/src/main/java/hudson/slaves/ConnectionActivityMonitor.java b/core/src/main/java/hudson/slaves/ConnectionActivityMonitor.java index 997a47525f..41d9aaa431 100644 --- a/core/src/main/java/hudson/slaves/ConnectionActivityMonitor.java +++ b/core/src/main/java/hudson/slaves/ConnectionActivityMonitor.java @@ -30,10 +30,8 @@ import hudson.model.Computer; import hudson.util.TimeUnit2; import hudson.remoting.VirtualChannel; import hudson.remoting.Channel; -import hudson.remoting.Callable; import hudson.Extension; -import jenkins.security.MasterToSlave; -import jenkins.security.SlaveToMaster; +import jenkins.security.SlaveToMasterCallable; import java.io.IOException; import java.util.logging.Logger; @@ -104,8 +102,7 @@ public class ConnectionActivityMonitor extends AsyncPeriodicWork { public boolean enabled = Boolean.getBoolean(ConnectionActivityMonitor.class.getName()+".enabled"); private static final PingCommand PING_COMMAND = new PingCommand(); - @MasterToSlave @SlaveToMaster - private static final class PingCommand implements Callable { + private static final class PingCommand extends SlaveToMasterCallable { public Void call() throws RuntimeException { return null; } diff --git a/core/src/main/java/hudson/slaves/SlaveComputer.java b/core/src/main/java/hudson/slaves/SlaveComputer.java index 1b7348128b..1b1517bd46 100644 --- a/core/src/main/java/hudson/slaves/SlaveComputer.java +++ b/core/src/main/java/hudson/slaves/SlaveComputer.java @@ -72,8 +72,7 @@ import javax.crypto.spec.IvParameterSpec; import javax.crypto.spec.SecretKeySpec; import javax.servlet.RequestDispatcher; import jenkins.model.Jenkins; -import jenkins.security.MasterToSlave; -import jenkins.security.SlaveToMaster; +import jenkins.security.MasterToSlaveCallable; import jenkins.slaves.JnlpSlaveAgentProtocol; import org.kohsuke.stapler.StaplerRequest; import org.kohsuke.stapler.StaplerResponse; @@ -401,8 +400,7 @@ public class SlaveComputer extends Computer { return channel.call(new LoadingTime(true)); } - @MasterToSlave @SlaveToMaster - static class LoadingCount implements Callable { + static class LoadingCount extends MasterToSlaveCallable { private final boolean resource; LoadingCount(boolean resource) { this.resource = resource; @@ -413,15 +411,13 @@ public class SlaveComputer extends Computer { } } - @MasterToSlave - static class LoadingPrefetchCacheCount implements Callable { + static class LoadingPrefetchCacheCount extends MasterToSlaveCallable { @Override public Integer call() { return Channel.current().classLoadingPrefetchCacheCount.get(); } } - @MasterToSlave - static class LoadingTime implements Callable { + static class LoadingTime extends MasterToSlaveCallable { private final boolean resource; LoadingTime(boolean resource) { this.resource = resource; @@ -716,22 +712,19 @@ public class SlaveComputer extends Computer { private static final Logger logger = Logger.getLogger(SlaveComputer.class.getName()); - @MasterToSlave - private static final class SlaveVersion implements Callable { + private static final class SlaveVersion extends MasterToSlaveCallable { public String call() throws IOException { try { return Launcher.VERSION; } catch (Throwable ex) { return "< 1.335"; } // Older slave.jar won't have VERSION } } - @MasterToSlave @SlaveToMaster - private static final class DetectOS implements Callable { + private static final class DetectOS extends MasterToSlaveCallable { public Boolean call() throws IOException { return File.pathSeparatorChar==':'; } } - @MasterToSlave @SlaveToMaster - private static final class DetectDefaultCharset implements Callable { + private static final class DetectDefaultCharset extends MasterToSlaveCallable { public String call() throws IOException { return Charset.defaultCharset().name(); } @@ -748,8 +741,7 @@ public class SlaveComputer extends Computer { static final RingBufferLogHandler SLAVE_LOG_HANDLER = new RingBufferLogHandler(); } - @MasterToSlave - private static class SlaveInitializer implements Callable { + private static class SlaveInitializer extends MasterToSlaveCallable { public Void call() { // avoid double installation of the handler. JNLP slaves can reconnect to the master multiple times // and each connection gets a different RemoteClassLoader, so we need to evict them by class name, @@ -796,8 +788,7 @@ public class SlaveComputer extends Computer { return null; } - @MasterToSlave - private static class SlaveLogFetcher implements Callable,RuntimeException> { + private static class SlaveLogFetcher extends MasterToSlaveCallable,RuntimeException> { public List call() { return new ArrayList(SLAVE_LOG_HANDLER.getView()); } diff --git a/core/src/main/java/hudson/tasks/ArtifactArchiver.java b/core/src/main/java/hudson/tasks/ArtifactArchiver.java index 7faa7b8986..a78aae14b2 100644 --- a/core/src/main/java/hudson/tasks/ArtifactArchiver.java +++ b/core/src/main/java/hudson/tasks/ArtifactArchiver.java @@ -24,6 +24,7 @@ package hudson.tasks; import hudson.FilePath; +import hudson.FilePath.MasterToSlaveFileCallable; import hudson.Launcher; import hudson.Util; import hudson.Extension; @@ -169,7 +170,7 @@ public class ArtifactArchiver extends Recorder { return true; } - private static final class ListFiles implements FilePath.FileCallable> { + private static final class ListFiles extends MasterToSlaveFileCallable> { private static final long serialVersionUID = 1; private final String includes, excludes; ListFiles(String includes, String excludes) { diff --git a/core/src/main/java/hudson/tasks/Fingerprinter.java b/core/src/main/java/hudson/tasks/Fingerprinter.java index f39828708b..a5a378b3f3 100644 --- a/core/src/main/java/hudson/tasks/Fingerprinter.java +++ b/core/src/main/java/hudson/tasks/Fingerprinter.java @@ -28,6 +28,7 @@ import hudson.EnvVars; import hudson.Extension; import hudson.FilePath; import hudson.FilePath.FileCallable; +import hudson.FilePath.MasterToSlaveFileCallable; import hudson.Launcher; import hudson.Util; import hudson.matrix.MatrixConfiguration; @@ -220,7 +221,7 @@ public class Fingerprinter extends Recorder implements Serializable, DependencyD return; } - List records = ws.act(new FileCallable>() { + List records = ws.act(new MasterToSlaveFileCallable>() { public List invoke(File baseDir, VirtualChannel channel) throws IOException { List results = new ArrayList(); diff --git a/core/src/main/java/hudson/tasks/Maven.java b/core/src/main/java/hudson/tasks/Maven.java index aed029341e..95c3f6f61e 100644 --- a/core/src/main/java/hudson/tasks/Maven.java +++ b/core/src/main/java/hudson/tasks/Maven.java @@ -24,6 +24,7 @@ package hudson.tasks; import hudson.Extension; +import hudson.FilePath.MasterToSlaveFileCallable; import hudson.Launcher; import hudson.Functions; import hudson.EnvVars; @@ -219,7 +220,7 @@ public class Maven extends Builder { * Looks for pom.xlm or project.xml to determine the maven executable * name. */ - private static final class DecideDefaultMavenCommand implements FileCallable { + private static final class DecideDefaultMavenCommand extends MasterToSlaveFileCallable { private static final long serialVersionUID = -2327576423452215146L; // command line arguments. private final String arguments; diff --git a/core/src/main/java/hudson/tasks/Shell.java b/core/src/main/java/hudson/tasks/Shell.java index 64c0192f6f..e7283accf3 100644 --- a/core/src/main/java/hudson/tasks/Shell.java +++ b/core/src/main/java/hudson/tasks/Shell.java @@ -28,12 +28,11 @@ import hudson.Functions; import hudson.Util; import hudson.Extension; import hudson.model.AbstractProject; -import hudson.remoting.Callable; import hudson.remoting.VirtualChannel; import hudson.util.FormValidation; import java.io.IOException; -import jenkins.security.MasterToSlave; +import jenkins.security.MasterToSlaveCallable; import net.sf.json.JSONObject; import org.kohsuke.stapler.DataBoundConstructor; import org.kohsuke.stapler.StaplerRequest; @@ -195,8 +194,7 @@ public class Shell extends CommandInterpreter { return FormValidation.validateExecutable(value); } - @MasterToSlave - private static final class Shellinterpreter implements Callable { + private static final class Shellinterpreter extends MasterToSlaveCallable { private static final long serialVersionUID = 1L; diff --git a/core/src/main/java/hudson/tasks/junit/JUnitParser.java b/core/src/main/java/hudson/tasks/junit/JUnitParser.java index 97b02f4fac..d72944263d 100644 --- a/core/src/main/java/hudson/tasks/junit/JUnitParser.java +++ b/core/src/main/java/hudson/tasks/junit/JUnitParser.java @@ -23,6 +23,7 @@ */ package hudson.tasks.junit; +import hudson.FilePath.MasterToSlaveFileCallable; import hudson.model.TaskListener; import hudson.tasks.test.TestResultParser; import hudson.model.AbstractBuild; @@ -87,8 +88,8 @@ public class JUnitParser extends TestResultParser { return workspace.act(new ParseResultCallable(testResultLocations, buildTime, timeOnMaster, keepLongStdio)); } - private static final class ParseResultCallable implements - FilePath.FileCallable { + private static final class ParseResultCallable extends + MasterToSlaveFileCallable { private final long buildTime; private final String testResults; private final long nowMaster; diff --git a/core/src/main/java/hudson/tasks/test/DefaultTestResultParserImpl.java b/core/src/main/java/hudson/tasks/test/DefaultTestResultParserImpl.java index ffd6db2859..ab364c0566 100644 --- a/core/src/main/java/hudson/tasks/test/DefaultTestResultParserImpl.java +++ b/core/src/main/java/hudson/tasks/test/DefaultTestResultParserImpl.java @@ -25,7 +25,7 @@ package hudson.tasks.test; import hudson.AbortException; import hudson.FilePath; -import hudson.FilePath.FileCallable; +import hudson.FilePath.MasterToSlaveFileCallable; import hudson.Launcher; import hudson.Util; import hudson.model.AbstractBuild; @@ -74,7 +74,7 @@ public abstract class DefaultTestResultParserImpl extends TestResultParser imple @Override public TestResult parse(final String testResultLocations, final AbstractBuild build, final Launcher launcher, final TaskListener listener) throws InterruptedException, IOException { - return build.getWorkspace().act(new FileCallable() { + return build.getWorkspace().act(new MasterToSlaveFileCallable() { final boolean ignoreTimestampCheck = IGNORE_TIMESTAMP_CHECK; // so that the property can be set on the master final long buildTime = build.getTimestamp().getTimeInMillis(); final long nowMaster = System.currentTimeMillis(); diff --git a/core/src/main/java/hudson/tools/JDKInstaller.java b/core/src/main/java/hudson/tools/JDKInstaller.java index 5bb4e377ef..3e5353b5ff 100644 --- a/core/src/main/java/hudson/tools/JDKInstaller.java +++ b/core/src/main/java/hudson/tools/JDKInstaller.java @@ -40,7 +40,7 @@ import hudson.util.FormValidation; import hudson.util.HttpResponses; import hudson.util.Secret; import jenkins.model.Jenkins; -import jenkins.security.MasterToSlave; +import jenkins.security.MasterToSlaveCallable; import net.sf.json.JSONObject; import org.apache.commons.httpclient.Cookie; import org.apache.commons.httpclient.HttpClient; @@ -502,8 +502,7 @@ public class JDKInstaller extends ToolInstaller { throw new DetectionFailedException("Unknown CPU name: "+arch); } - @MasterToSlave - static class GetCurrentPlatform implements Callable { + static class GetCurrentPlatform extends MasterToSlaveCallable { private static final long serialVersionUID = 1L; public Platform call() throws DetectionFailedException { return current(); @@ -565,8 +564,7 @@ public class JDKInstaller extends ToolInstaller { throw new DetectionFailedException("Unknown CPU architecture: "+arch); } - @MasterToSlave - static class GetCurrentCPU implements Callable { + static class GetCurrentCPU extends MasterToSlaveCallable { private static final long serialVersionUID = 1L; public CPU call() throws DetectionFailedException { return current(); diff --git a/core/src/main/java/hudson/tools/ZipExtractionInstaller.java b/core/src/main/java/hudson/tools/ZipExtractionInstaller.java index 48ef62b97c..ff3b3837ec 100644 --- a/core/src/main/java/hudson/tools/ZipExtractionInstaller.java +++ b/core/src/main/java/hudson/tools/ZipExtractionInstaller.java @@ -26,7 +26,7 @@ package hudson.tools; import hudson.Extension; import hudson.FilePath; -import hudson.FilePath.FileCallable; +import hudson.FilePath.MasterToSlaveFileCallable; import hudson.ProxyConfiguration; import hudson.Util; import hudson.Functions; @@ -119,7 +119,7 @@ public class ZipExtractionInstaller extends ToolInstaller { * Sets execute permission on all files, since unzip etc. might not do this. * Hackish, is there a better way? */ - static class ChmodRecAPlusX implements FileCallable { + static class ChmodRecAPlusX extends MasterToSlaveFileCallable { private static final long serialVersionUID = 1L; public Void invoke(File d, VirtualChannel channel) throws IOException { if(!Functions.isWindows()) diff --git a/core/src/main/java/hudson/util/RemotingDiagnostics.java b/core/src/main/java/hudson/util/RemotingDiagnostics.java index a0edd54abf..5dc4c430a5 100644 --- a/core/src/main/java/hudson/util/RemotingDiagnostics.java +++ b/core/src/main/java/hudson/util/RemotingDiagnostics.java @@ -34,7 +34,7 @@ import hudson.remoting.DelegatingCallable; import hudson.remoting.Future; import hudson.remoting.VirtualChannel; import hudson.security.AccessControlled; -import jenkins.security.MasterToSlave; +import jenkins.security.MasterToSlaveCallable; import org.codehaus.groovy.control.CompilerConfiguration; import org.codehaus.groovy.control.customizers.ImportCustomizer; import org.kohsuke.stapler.StaplerRequest; @@ -71,8 +71,7 @@ public final class RemotingDiagnostics { return channel.call(new GetSystemProperties()); } - @MasterToSlave - private static final class GetSystemProperties implements Callable,RuntimeException> { + private static final class GetSystemProperties extends MasterToSlaveCallable,RuntimeException> { public Map call() { return new TreeMap(System.getProperties()); } @@ -91,8 +90,7 @@ public final class RemotingDiagnostics { return channel.callAsync(new GetThreadDump()); } - @MasterToSlave - private static final class GetThreadDump implements Callable,RuntimeException> { + private static final class GetThreadDump extends MasterToSlaveCallable,RuntimeException> { public Map call() { Map r = new LinkedHashMap(); try { @@ -122,8 +120,7 @@ public final class RemotingDiagnostics { return channel.call(new Script(script)); } - @MasterToSlave - private static final class Script implements DelegatingCallable { + private static final class Script extends MasterToSlaveCallable implements DelegatingCallable { private final String script; private transient ClassLoader cl; @@ -205,8 +202,7 @@ public final class RemotingDiagnostics { } } - @MasterToSlave - private static class GetHeapDump implements Callable { + private static class GetHeapDump extends MasterToSlaveCallable { public FilePath call() throws IOException { final File hprof = File.createTempFile("hudson-heapdump", "hprof"); hprof.delete(); diff --git a/core/src/main/java/jenkins/security/MasterToSlave.java b/core/src/main/java/jenkins/security/MasterToSlave.java deleted file mode 100644 index 832af307a3..0000000000 --- a/core/src/main/java/jenkins/security/MasterToSlave.java +++ /dev/null @@ -1,25 +0,0 @@ -package jenkins.security; - -import hudson.remoting.Callable; - -import java.lang.annotation.Documented; -import java.lang.annotation.Inherited; -import java.lang.annotation.Retention; -import java.lang.annotation.Target; - -import static java.lang.annotation.ElementType.TYPE; -import static java.lang.annotation.RetentionPolicy.RUNTIME; - -/** - * Annotates {@link Callable} that this callable is meant to be run on the slave. - * - * @author Kohsuke Kawaguchi - * @see SlaveToMaster - * @since 1.THU - */ -@Retention(RUNTIME) -@Target(TYPE) -@Inherited -@Documented -public @interface MasterToSlave { -} diff --git a/core/src/main/java/jenkins/security/MasterToSlaveCallable.java b/core/src/main/java/jenkins/security/MasterToSlaveCallable.java index 1834a08560..1d498d290e 100644 --- a/core/src/main/java/jenkins/security/MasterToSlaveCallable.java +++ b/core/src/main/java/jenkins/security/MasterToSlaveCallable.java @@ -1,14 +1,21 @@ package jenkins.security; import hudson.remoting.Callable; +import org.jenkinsci.remoting.Role; + +import java.util.Collection; /** - * Convenient {@link Callable} with {@link MasterToSlave} to create anonymous Callable class. + * Convenient {@link Callable} meant to be run on slave. * * @author Kohsuke Kawaguchi * @since 1.THU */ -@MasterToSlave public abstract class MasterToSlaveCallable implements Callable { + @Override + public Collection getRecipients() { + return Roles.FOR_SLAVE; + } + private static final long serialVersionUID = 1L; } diff --git a/core/src/main/java/jenkins/security/NotReallyRoleSensitiveCallable.java b/core/src/main/java/jenkins/security/NotReallyRoleSensitiveCallable.java new file mode 100644 index 0000000000..5663cd7575 --- /dev/null +++ b/core/src/main/java/jenkins/security/NotReallyRoleSensitiveCallable.java @@ -0,0 +1,21 @@ +package jenkins.security; + +import hudson.remoting.Callable; +import org.jenkinsci.remoting.Role; + +import java.util.Collection; + +/** + * {@link Callable} adapter for situations where Callable is not used for remoting but + * just as a convenient function that has parameterized return value and exception type. + * + * @author Kohsuke Kawaguchi + * @since 1.THU + */ +public abstract class NotReallyRoleSensitiveCallable implements Callable { + @Override + public final Collection getRecipients() { + // not meant to be used where this matters + throw new UnsupportedOperationException(); + } +} diff --git a/core/src/main/java/jenkins/security/SlaveToMaster.java b/core/src/main/java/jenkins/security/SlaveToMaster.java deleted file mode 100644 index d5ececbd22..0000000000 --- a/core/src/main/java/jenkins/security/SlaveToMaster.java +++ /dev/null @@ -1,26 +0,0 @@ -package jenkins.security; - -import hudson.remoting.Callable; - -import java.lang.annotation.Documented; -import java.lang.annotation.Inherited; -import java.lang.annotation.Retention; -import java.lang.annotation.Target; - -import static java.lang.annotation.ElementType.*; -import static java.lang.annotation.RetentionPolicy.*; - -/** - * Annotates {@link Callable} that are meant for the slave to execute on the master. - * - * @author Kohsuke Kawaguchi - * @see MasterToSlave - * @see CallableDirectionChecker - * @since 1.THU - */ -@Retention(RUNTIME) -@Target(TYPE) -@Inherited -@Documented -public @interface SlaveToMaster { -} diff --git a/core/src/main/java/jenkins/security/SlaveToMasterCallable.java b/core/src/main/java/jenkins/security/SlaveToMasterCallable.java index 0a05dc22d8..cb5fd1a082 100644 --- a/core/src/main/java/jenkins/security/SlaveToMasterCallable.java +++ b/core/src/main/java/jenkins/security/SlaveToMasterCallable.java @@ -1,14 +1,21 @@ package jenkins.security; import hudson.remoting.Callable; +import org.jenkinsci.remoting.Role; + +import java.util.Collection; /** - * Convenient {@link Callable} with {@link SlaveToMaster} to create anonymous Callable class. + * Convenient {@link Callable} that are meant to run on the master (sent by slave/CLI/etc). * * @author Kohsuke Kawaguchi * @since 1.THU */ -@SlaveToMaster public abstract class SlaveToMasterCallable implements Callable { + @Override + public Collection getRecipients() { + return Roles.FOR_MASTER; + } + private static final long serialVersionUID = 1L; } diff --git a/core/src/main/java/jenkins/slaves/StandardOutputSwapper.java b/core/src/main/java/jenkins/slaves/StandardOutputSwapper.java index f0bb18593d..51b7e2af74 100644 --- a/core/src/main/java/jenkins/slaves/StandardOutputSwapper.java +++ b/core/src/main/java/jenkins/slaves/StandardOutputSwapper.java @@ -4,12 +4,11 @@ import hudson.Extension; import hudson.FilePath; import hudson.model.Computer; import hudson.model.TaskListener; -import hudson.remoting.Callable; import hudson.remoting.Channel; import hudson.remoting.StandardOutputStream; import hudson.slaves.ComputerListener; import hudson.util.jna.GNUCLibrary; -import jenkins.security.MasterToSlave; +import jenkins.security.MasterToSlaveCallable; import java.io.File; import java.io.FileDescriptor; @@ -36,8 +35,7 @@ public class StandardOutputSwapper extends ComputerListener { } } - @MasterToSlave - private static final class ChannelSwapper implements Callable { + private static final class ChannelSwapper extends MasterToSlaveCallable { public Boolean call() throws Exception { if (File.pathSeparatorChar==';') return false; // Windows diff --git a/core/src/main/java/jenkins/util/VirtualFile.java b/core/src/main/java/jenkins/util/VirtualFile.java index 5c985ac9c9..bf6017d616 100644 --- a/core/src/main/java/jenkins/util/VirtualFile.java +++ b/core/src/main/java/jenkins/util/VirtualFile.java @@ -39,6 +39,8 @@ import java.util.ArrayList; import java.util.List; import javax.annotation.Nonnull; +import static hudson.FilePath.MasterToSlaveFileCallable; + /** * Abstraction over {@link File}, {@link FilePath}, or other items such as network resources or ZIP entries. * Assumed to be read-only and makes very limited assumptions, just enough to display content and traverse directories. @@ -334,7 +336,7 @@ public abstract class VirtualFile implements Comparable { } }; } - private static final class Scanner implements FilePath.FileCallable { + private static final class Scanner extends MasterToSlaveFileCallable { private final String glob; Scanner(String glob) { this.glob = glob; @@ -351,7 +353,7 @@ public abstract class VirtualFile implements Comparable { } } - private static final class Readable implements FilePath.FileCallable { + private static final class Readable extends MasterToSlaveFileCallable { @Override public Boolean invoke(File f, VirtualChannel channel) throws IOException, InterruptedException { return f.canRead(); } diff --git a/core/src/test/java/hudson/LauncherTest.java b/core/src/test/java/hudson/LauncherTest.java index 620d95ffb2..13ea826660 100644 --- a/core/src/test/java/hudson/LauncherTest.java +++ b/core/src/test/java/hudson/LauncherTest.java @@ -31,6 +31,8 @@ import hudson.util.ProcessTree; import hudson.util.StreamTaskListener; import hudson.remoting.Callable; import java.io.ByteArrayOutputStream; + +import jenkins.security.MasterToSlaveCallable; import org.apache.commons.io.FileUtils; import org.jvnet.hudson.test.Bug; @@ -74,7 +76,7 @@ public class LauncherTest extends ChannelTestCase { } } - private static final Callable NOOP = new Callable() { + private static final Callable NOOP = new MasterToSlaveCallable() { public Object call() throws RuntimeException { return null; } diff --git a/core/src/test/java/hudson/os/SUTester.java b/core/src/test/java/hudson/os/SUTester.java index 2f28a41303..c89d447c0c 100644 --- a/core/src/test/java/hudson/os/SUTester.java +++ b/core/src/test/java/hudson/os/SUTester.java @@ -2,6 +2,7 @@ package hudson.os; import hudson.remoting.Callable; import hudson.util.StreamTaskListener; +import jenkins.security.MasterToSlaveCallable; import java.io.FileOutputStream; @@ -10,7 +11,7 @@ import java.io.FileOutputStream; */ public class SUTester { public static void main(String[] args) throws Throwable { - SU.execute(StreamTaskListener.fromStdout(),"kohsuke","bogus",new Callable() { + SU.execute(StreamTaskListener.fromStdout(),"kohsuke","bogus",new MasterToSlaveCallable() { public Object call() throws Throwable { System.out.println("Touching /tmp/x"); new FileOutputStream("/tmp/x").close(); diff --git a/core/src/test/java/hudson/util/ProcessTreeTest.java b/core/src/test/java/hudson/util/ProcessTreeTest.java index dd531eac3c..9cea1f228e 100644 --- a/core/src/test/java/hudson/util/ProcessTreeTest.java +++ b/core/src/test/java/hudson/util/ProcessTreeTest.java @@ -5,6 +5,7 @@ import hudson.remoting.Callable; import hudson.remoting.VirtualChannel; import hudson.util.ProcessTree.OSProcess; import hudson.util.ProcessTree.ProcessCallable; +import jenkins.security.MasterToSlaveCallable; import java.io.IOException; import java.io.Serializable; @@ -35,7 +36,7 @@ public class ProcessTreeTest extends ChannelTestCase { t.p.act(new ProcessCallableImpl()); } - private static class MyCallable implements Callable, Serializable { + private static class MyCallable extends MasterToSlaveCallable implements Serializable { public Tag call() throws IOException { Tag t = new Tag(); t.tree = ProcessTree.get(); diff --git a/test/src/test/java/hudson/ProcTest.java b/test/src/test/java/hudson/ProcTest.java index 5eb7752768..6159fc6edd 100644 --- a/test/src/test/java/hudson/ProcTest.java +++ b/test/src/test/java/hudson/ProcTest.java @@ -3,13 +3,12 @@ package hudson; import hudson.Launcher.LocalLauncher; import hudson.Launcher.RemoteLauncher; import hudson.Proc.RemoteProc; -import hudson.remoting.Callable; -import hudson.remoting.Future; import hudson.remoting.Pipe; import hudson.remoting.VirtualChannel; import hudson.slaves.DumbSlave; import hudson.util.IOUtils; import hudson.util.StreamTaskListener; +import jenkins.security.MasterToSlaveCallable; import org.jvnet.hudson.test.Bug; import org.jvnet.hudson.test.HudsonTestCase; @@ -70,7 +69,7 @@ public class ProcTest extends HudsonTestCase { return ch; } - private static class ChannelFiller implements Callable { + private static class ChannelFiller extends MasterToSlaveCallable { private final OutputStream o; private ChannelFiller(OutputStream o) { diff --git a/test/src/test/java/hudson/logging/LogRecorderManagerTest.java b/test/src/test/java/hudson/logging/LogRecorderManagerTest.java index 4bcd2469e7..d27ea875c4 100644 --- a/test/src/test/java/hudson/logging/LogRecorderManagerTest.java +++ b/test/src/test/java/hudson/logging/LogRecorderManagerTest.java @@ -23,6 +23,7 @@ */ package hudson.logging; +import jenkins.security.MasterToSlaveCallable; import org.jvnet.hudson.test.Url; import com.gargoylesoftware.htmlunit.html.HtmlPage; import com.gargoylesoftware.htmlunit.html.HtmlForm; @@ -109,7 +110,7 @@ public class LogRecorderManagerTest { assertFalse(text, text.contains("msg #4")); } - private static final class Log implements Callable { + private static final class Log extends MasterToSlaveCallable { private final Level level; private final String logger; private final String message; diff --git a/test/src/test/java/hudson/slaves/JNLPLauncherTest.java b/test/src/test/java/hudson/slaves/JNLPLauncherTest.java index 8d1e6bf7f4..26e7c1a1a2 100644 --- a/test/src/test/java/hudson/slaves/JNLPLauncherTest.java +++ b/test/src/test/java/hudson/slaves/JNLPLauncherTest.java @@ -35,8 +35,7 @@ import hudson.remoting.Callable; import hudson.remoting.Which; import hudson.util.ArgumentListBuilder; -import jenkins.security.MasterToSlave; -import jenkins.security.SlaveToMaster; +import jenkins.security.SlaveToMasterCallable; import org.jvnet.hudson.test.HudsonTestCase; import org.jvnet.hudson.test.TestExtension; @@ -156,8 +155,7 @@ public class JNLPLauncherTest extends HudsonTestCase { return c; } - @MasterToSlave @SlaveToMaster - private static class NoopTask implements Callable { + private static class NoopTask extends SlaveToMasterCallable { public String call() { return "done"; } diff --git a/test/src/test/java/jenkins/security/DefaultFilePathFilterTest.java b/test/src/test/java/jenkins/security/DefaultFilePathFilterTest.java index 80c4cef801..3d10d97a26 100644 --- a/test/src/test/java/jenkins/security/DefaultFilePathFilterTest.java +++ b/test/src/test/java/jenkins/security/DefaultFilePathFilterTest.java @@ -28,6 +28,9 @@ import hudson.FilePath; import hudson.model.Slave; import hudson.remoting.Callable; import java.io.File; +import java.util.Collection; + +import org.jenkinsci.remoting.Role; import org.junit.Test; import static org.junit.Assert.*; import org.junit.Rule; @@ -51,7 +54,7 @@ public class DefaultFilePathFilterTest { // good } assertFalse(reverse.exists()); - System.setProperty(DefaultFilePathFilter.BYPASS_PROP, "true"); + DefaultFilePathFilter.BYPASS = true; s.getChannel().call(new ReverseCallable(reverse)); assertTrue(reverse.exists()); assertEquals("goodbye", reverse.readToString()); @@ -66,6 +69,10 @@ public class DefaultFilePathFilterTest { assertFalse(p.isRemote()); return p.readToString(); } + @Override + public Collection getRecipients() { + return null; // simulate legacy Callable impls + } } private static class ReverseCallable implements Callable { @@ -78,6 +85,9 @@ public class DefaultFilePathFilterTest { p.write("goodbye", null); return null; } + @Override + public Collection getRecipients() { + return null; // simulate legacy Callable impls + } } - }