diff --git a/core/src/main/java/hudson/FilePath.java b/core/src/main/java/hudson/FilePath.java index 74331a522f..51bf76f324 100644 --- a/core/src/main/java/hudson/FilePath.java +++ b/core/src/main/java/hudson/FilePath.java @@ -25,41 +25,50 @@ */ package hudson; +import com.jcraft.jzlib.GZIPInputStream; +import com.jcraft.jzlib.GZIPOutputStream; import hudson.Launcher.LocalLauncher; import hudson.Launcher.RemoteLauncher; -import hudson.os.PosixAPI; -import jenkins.model.Jenkins; -import hudson.model.TaskListener; import hudson.model.AbstractProject; import hudson.model.Item; +import hudson.model.TaskListener; +import hudson.org.apache.tools.tar.TarInputStream; +import hudson.os.PosixAPI; +import hudson.os.PosixException; import hudson.remoting.Callable; import hudson.remoting.Channel; import hudson.remoting.DelegatingCallable; import hudson.remoting.Future; +import hudson.remoting.LocalChannel; import hudson.remoting.Pipe; +import hudson.remoting.RemoteInputStream; import hudson.remoting.RemoteOutputStream; import hudson.remoting.VirtualChannel; -import hudson.remoting.RemoteInputStream; import hudson.remoting.Which; import hudson.security.AccessControlled; +import hudson.util.DaemonThreadFactory; import hudson.util.DirScanner; -import hudson.util.HeadBufferingStream; +import hudson.util.ExceptionCatchingThreadFactory; +import hudson.util.FileVisitor; import hudson.util.FormValidation; +import hudson.util.HeadBufferingStream; import hudson.util.IOUtils; - -import static hudson.Util.*; -import static hudson.FilePath.TarCompression.GZIP; -import hudson.org.apache.tools.tar.TarInputStream; +import hudson.util.NamingThreadFactory; import hudson.util.io.Archiver; import hudson.util.io.ArchiverFactory; +import jenkins.model.Jenkins; +import jenkins.util.ContextResettingExecutorService; import jenkins.util.VirtualFile; +import org.apache.commons.fileupload.FileItem; +import org.apache.commons.io.input.CountingInputStream; import org.apache.tools.ant.DirectoryScanner; import org.apache.tools.ant.Project; import org.apache.tools.ant.types.FileSet; import org.apache.tools.tar.TarEntry; -import org.apache.commons.io.input.CountingInputStream; -import org.apache.commons.fileupload.FileItem; +import org.apache.tools.zip.ZipEntry; +import org.apache.tools.zip.ZipFile; import org.kohsuke.stapler.Stapler; + import java.io.BufferedOutputStream; import java.io.File; import java.io.FileFilter; @@ -72,37 +81,34 @@ import java.io.InterruptedIOException; import java.io.ObjectInputStream; import java.io.ObjectOutputStream; import java.io.OutputStream; +import java.io.OutputStreamWriter; import java.io.Serializable; import java.io.Writer; -import java.io.OutputStreamWriter; import java.lang.reflect.Field; import java.net.HttpURLConnection; import java.net.URI; import java.net.URL; import java.net.URLConnection; import java.util.ArrayList; -import java.util.List; -import java.util.StringTokenizer; import java.util.Arrays; import java.util.Comparator; -import java.util.logging.Level; -import java.util.regex.Matcher; -import java.util.regex.Pattern; +import java.util.Enumeration; +import java.util.List; +import java.util.Map; +import java.util.StringTokenizer; import java.util.concurrent.ExecutionException; +import java.util.concurrent.ExecutorService; +import java.util.concurrent.Executors; import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeoutException; -import com.jcraft.jzlib.GZIPInputStream; -import com.jcraft.jzlib.GZIPOutputStream; - -import hudson.os.PosixException; -import hudson.util.FileVisitor; -import java.util.Enumeration; -import java.util.Map; import java.util.concurrent.atomic.AtomicInteger; +import java.util.logging.Level; import java.util.logging.Logger; +import java.util.regex.Matcher; +import java.util.regex.Pattern; -import org.apache.tools.zip.ZipFile; -import org.apache.tools.zip.ZipEntry; +import static hudson.FilePath.TarCompression.*; +import static hudson.Util.*; /** * {@link File} like object with remoting support. @@ -196,7 +202,7 @@ public final class FilePath implements Serializable { * that's connected to that machine. If null, that means the local file path. */ public FilePath(VirtualChannel channel, String remote) { - this.channel = channel == Jenkins.MasterComputer.localChannel ? null : channel; + this.channel = channel instanceof LocalChannel ? null : channel; this.remote = normalize(remote); } @@ -911,7 +917,7 @@ public final class FilePath implements Serializable { } } else { // the file is on the local machine. - return callable.invoke(new File(remote), Jenkins.MasterComputer.localChannel); + return callable.invoke(new File(remote), localChannel); } } @@ -985,7 +991,7 @@ public final class FilePath implements Serializable { } } - return (channel!=null ? channel : Jenkins.MasterComputer.localChannel) + return (channel!=null ? channel : localChannel) .callAsync(wrapper); } catch (IOException e) { // wrap it into a new IOException so that we get the caller's stack trace as well. @@ -2402,7 +2408,7 @@ public final class FilePath implements Serializable { public VirtualChannel getChannel() { if(channel!=null) return channel; - else return Jenkins.MasterComputer.localChannel; + else return localChannel; } /** @@ -2544,4 +2550,11 @@ public final class FilePath implements Serializable { } + private static final ExecutorService threadPoolForRemoting = new ContextResettingExecutorService( + Executors.newCachedThreadPool( + new ExceptionCatchingThreadFactory( + new NamingThreadFactory(new DaemonThreadFactory(), "FilePath.localPool")) + )); + + public static final LocalChannel localChannel = new LocalChannel(threadPoolForRemoting); } diff --git a/core/src/main/java/hudson/Launcher.java b/core/src/main/java/hudson/Launcher.java index 51a9180745..6822a5c8ca 100644 --- a/core/src/main/java/hudson/Launcher.java +++ b/core/src/main/java/hudson/Launcher.java @@ -754,7 +754,7 @@ public abstract class Launcher { */ public static class LocalLauncher extends Launcher { public LocalLauncher(TaskListener listener) { - this(listener, Jenkins.MasterComputer.localChannel); + this(listener, FilePath.localChannel); } public LocalLauncher(TaskListener listener, VirtualChannel channel) { diff --git a/core/src/main/java/hudson/cli/ClientAuthenticationCache.java b/core/src/main/java/hudson/cli/ClientAuthenticationCache.java index 6b8ef61d73..3f9479c6e7 100644 --- a/core/src/main/java/hudson/cli/ClientAuthenticationCache.java +++ b/core/src/main/java/hudson/cli/ClientAuthenticationCache.java @@ -1,11 +1,10 @@ package hudson.cli; import hudson.FilePath; -import jenkins.model.Jenkins; -import jenkins.model.Jenkins.MasterComputer; import hudson.remoting.Callable; import hudson.remoting.Channel; import hudson.util.Secret; +import jenkins.model.Jenkins; import org.acegisecurity.Authentication; import org.acegisecurity.AuthenticationException; import org.acegisecurity.providers.UsernamePasswordAuthenticationToken; @@ -40,7 +39,7 @@ public class ClientAuthenticationCache implements Serializable { private final Properties props = new Properties(); public ClientAuthenticationCache(Channel channel) throws IOException, InterruptedException { - store = (channel==null ? MasterComputer.localChannel : channel).call(new Callable() { + store = (channel==null ? FilePath.localChannel : channel).call(new Callable() { public FilePath call() throws IOException { File home = new File(System.getProperty("user.home")); File hudsonHome = new File(home, ".hudson"); diff --git a/core/src/main/java/hudson/os/SU.java b/core/src/main/java/hudson/os/SU.java index b254f54c43..6a2b8abfa2 100644 --- a/core/src/main/java/hudson/os/SU.java +++ b/core/src/main/java/hudson/os/SU.java @@ -24,6 +24,7 @@ package hudson.os; import com.sun.solaris.EmbeddedSu; +import hudson.FilePath; import hudson.Launcher.LocalLauncher; import hudson.Util; import hudson.model.Computer; @@ -35,13 +36,14 @@ import hudson.remoting.VirtualChannel; import hudson.remoting.Which; import hudson.slaves.Channels; import hudson.util.ArgumentListBuilder; -import static hudson.util.jna.GNUCLibrary.LIBC; import java.io.File; import java.io.IOException; import java.io.PrintStream; import java.util.Collections; +import static hudson.util.jna.GNUCLibrary.*; + /** * Executes {@link Callable} as the super user, by forking a new process and executing the closure in there * if necessary. @@ -116,7 +118,7 @@ public abstract class SU { } private static LocalChannel newLocalChannel() { - return new LocalChannel(Computer.threadPoolForRemoting); + return FilePath.localChannel; } /** diff --git a/core/src/main/java/hudson/slaves/SlaveComputer.java b/core/src/main/java/hudson/slaves/SlaveComputer.java index 4bd6edd9b3..d83974c6cd 100644 --- a/core/src/main/java/hudson/slaves/SlaveComputer.java +++ b/core/src/main/java/hudson/slaves/SlaveComputer.java @@ -23,51 +23,30 @@ */ package hudson.slaves; -import hudson.model.*; -import hudson.util.io.ReopenableRotatingFileOutputStream; -import jenkins.model.Jenkins.MasterComputer; -import hudson.remoting.Channel; -import hudson.remoting.VirtualChannel; -import hudson.remoting.Callable; -import hudson.util.StreamTaskListener; -import hudson.util.NullStream; -import hudson.util.RingBufferLogHandler; -import hudson.util.Futures; +import hudson.AbortException; import hudson.FilePath; import hudson.Util; -import hudson.AbortException; +import hudson.model.Computer; +import hudson.model.Executor; +import hudson.model.ExecutorListener; +import hudson.model.Node; +import hudson.model.Queue; +import hudson.model.Slave; +import hudson.model.TaskListener; +import hudson.model.User; +import hudson.remoting.Callable; +import hudson.remoting.Channel; import hudson.remoting.Launcher; +import hudson.remoting.VirtualChannel; import hudson.security.ACL; -import static hudson.slaves.SlaveComputer.LogHolder.SLAVE_LOG_HANDLER; import hudson.slaves.OfflineCause.ChannelTermination; +import hudson.util.Futures; +import hudson.util.NullStream; +import hudson.util.RingBufferLogHandler; import hudson.util.Secret; - -import java.io.File; -import java.io.OutputStream; -import java.io.InputStream; -import java.io.IOException; -import java.io.PrintStream; -import java.security.SecureRandom; -import java.util.logging.Level; -import java.util.logging.LogRecord; -import java.util.logging.Logger; -import java.util.logging.Handler; -import java.util.List; -import java.util.Collections; -import java.util.ArrayList; -import java.nio.charset.Charset; -import java.util.concurrent.Future; -import java.security.Security; - +import hudson.util.StreamTaskListener; import hudson.util.io.ReopenableFileOutputStream; -import java.io.ByteArrayOutputStream; -import java.io.PrintWriter; -import java.security.GeneralSecurityException; -import javax.crypto.Cipher; -import javax.crypto.SecretKey; -import javax.crypto.spec.IvParameterSpec; -import javax.crypto.spec.SecretKeySpec; -import javax.servlet.RequestDispatcher; +import hudson.util.io.ReopenableRotatingFileOutputStream; import jenkins.model.Jenkins; import jenkins.slaves.JnlpSlaveAgentProtocol; import jenkins.slaves.systemInfo.SlaveSystemInfo; @@ -83,10 +62,45 @@ import javax.servlet.http.HttpServletResponseWrapper; import org.acegisecurity.context.SecurityContext; import org.acegisecurity.context.SecurityContextHolder; import org.apache.commons.io.IOUtils; +import org.kohsuke.stapler.HttpRedirect; +import org.kohsuke.stapler.HttpResponse; +import org.kohsuke.stapler.QueryParameter; import org.kohsuke.stapler.ResponseImpl; +import org.kohsuke.stapler.StaplerRequest; +import org.kohsuke.stapler.StaplerResponse; import org.kohsuke.stapler.WebMethod; import org.kohsuke.stapler.compression.FilterServletOutputStream; +import javax.crypto.Cipher; +import javax.crypto.SecretKey; +import javax.crypto.spec.IvParameterSpec; +import javax.crypto.spec.SecretKeySpec; +import javax.servlet.RequestDispatcher; +import javax.servlet.ServletException; +import javax.servlet.ServletOutputStream; +import javax.servlet.http.HttpServletResponseWrapper; +import java.io.ByteArrayOutputStream; +import java.io.File; +import java.io.IOException; +import java.io.InputStream; +import java.io.OutputStream; +import java.io.PrintStream; +import java.io.PrintWriter; +import java.nio.charset.Charset; +import java.security.GeneralSecurityException; +import java.security.SecureRandom; +import java.security.Security; +import java.util.ArrayList; +import java.util.Collections; +import java.util.List; +import java.util.concurrent.Future; +import java.util.logging.Handler; +import java.util.logging.Level; +import java.util.logging.LogRecord; +import java.util.logging.Logger; + +import static hudson.slaves.SlaveComputer.LogHolder.*; + /** * {@link Computer} for {@link Slave}s. * @@ -765,7 +779,7 @@ public class SlaveComputer extends Computer { */ public static VirtualChannel getChannelToMaster() { if (Jenkins.getInstance()!=null) - return MasterComputer.localChannel; + return FilePath.localChannel; // if this method is called from within the slave computation thread, this should work Channel c = Channel.current(); diff --git a/core/src/main/java/hudson/util/ProcessTree.java b/core/src/main/java/hudson/util/ProcessTree.java index 23e5cb3b91..2866b63b8f 100644 --- a/core/src/main/java/hudson/util/ProcessTree.java +++ b/core/src/main/java/hudson/util/ProcessTree.java @@ -27,6 +27,7 @@ import com.sun.jna.Memory; import com.sun.jna.Native; import com.sun.jna.ptr.IntByReference; import hudson.EnvVars; +import hudson.FilePath; import hudson.Util; import jenkins.model.Jenkins; import hudson.remoting.Callable; @@ -278,7 +279,7 @@ public abstract class ProcessTree implements Iterable, IProcessTree, * Executes a chunk of code at the same machine where this process resides. */ public T act(ProcessCallable callable) throws IOException, InterruptedException { - return callable.invoke(this, Jenkins.MasterComputer.localChannel); + return callable.invoke(this, FilePath.localChannel); } Object writeReplace() { diff --git a/core/src/main/java/jenkins/model/Jenkins.java b/core/src/main/java/jenkins/model/Jenkins.java index 5ec8026ab8..5e994b8e53 100644 --- a/core/src/main/java/jenkins/model/Jenkins.java +++ b/core/src/main/java/jenkins/model/Jenkins.java @@ -26,14 +26,44 @@ */ package jenkins.model; +import antlr.ANTLRException; +import com.google.common.collect.ImmutableMap; import com.google.common.collect.Lists; import com.google.inject.Injector; +import com.thoughtworks.xstream.XStream; +import hudson.BulkChange; +import hudson.DNSMultiCast; +import hudson.DescriptorExtensionList; +import hudson.Extension; import hudson.ExtensionComponent; import hudson.ExtensionFinder; -import hudson.init.*; -import hudson.model.LoadStatistics; -import hudson.model.Messages; -import hudson.model.Node; +import hudson.ExtensionList; +import hudson.ExtensionPoint; +import hudson.FilePath; +import hudson.Functions; +import hudson.Launcher; +import hudson.Launcher.LocalLauncher; +import hudson.LocalPluginManager; +import hudson.Lookup; +import hudson.Plugin; +import hudson.PluginManager; +import hudson.PluginWrapper; +import hudson.ProxyConfiguration; +import hudson.TcpSlaveAgentListener; +import hudson.UDPBroadcastThread; +import hudson.Util; +import hudson.WebAppMain; +import hudson.XmlFile; +import hudson.cli.declarative.CLIMethod; +import hudson.cli.declarative.CLIResolver; +import hudson.init.InitMilestone; +import hudson.init.InitStrategy; +import hudson.init.TerminatorFinder; +import hudson.lifecycle.Lifecycle; +import hudson.lifecycle.RestartNotSupportedException; +import hudson.logging.LogRecorderManager; +import hudson.markup.EscapedMarkupFormatter; +import hudson.markup.MarkupFormatter; import hudson.model.AbstractCIBase; import hudson.model.AbstractProject; import hudson.model.Action; @@ -45,6 +75,7 @@ import hudson.model.ComputerSet; import hudson.model.DependencyGraph; import hudson.model.Describable; import hudson.model.Descriptor; +import hudson.model.Descriptor.FormException; import hudson.model.DescriptorByNameOwner; import hudson.model.DirectoryBrowserSupport; import hudson.model.Failure; @@ -56,18 +87,22 @@ import hudson.model.Item; import hudson.model.ItemGroup; import hudson.model.ItemGroupMixIn; import hudson.model.Items; -import hudson.model.ModifiableViewGroup; import hudson.model.JDK; import hudson.model.Job; import hudson.model.JobPropertyDescriptor; import hudson.model.Label; import hudson.model.ListView; import hudson.model.LoadBalancer; +import hudson.model.LoadStatistics; import hudson.model.ManagementLink; +import hudson.model.Messages; +import hudson.model.ModifiableViewGroup; import hudson.model.NoFingerprintMatch; +import hudson.model.Node; import hudson.model.OverallLoadStatistics; import hudson.model.PaneStatusProperties; import hudson.model.Project; +import hudson.model.Queue; import hudson.model.Queue.FlyweightTask; import hudson.model.RestartListener; import hudson.model.RootAction; @@ -80,47 +115,11 @@ import hudson.model.UpdateCenter; import hudson.model.User; import hudson.model.View; import hudson.model.ViewGroupMixIn; -import hudson.model.Descriptor.FormException; +import hudson.model.WorkspaceCleanupThread; import hudson.model.labels.LabelAtom; import hudson.model.listeners.ItemListener; import hudson.model.listeners.SCMListener; import hudson.model.listeners.SaveableListener; -import hudson.model.Queue; -import hudson.model.WorkspaceCleanupThread; - -import antlr.ANTLRException; -import com.google.common.collect.ImmutableMap; -import com.thoughtworks.xstream.XStream; -import hudson.BulkChange; -import hudson.DNSMultiCast; -import hudson.DescriptorExtensionList; -import hudson.Extension; -import hudson.ExtensionList; -import hudson.ExtensionPoint; -import hudson.FilePath; -import hudson.Functions; -import hudson.Launcher; -import hudson.Launcher.LocalLauncher; -import hudson.LocalPluginManager; -import hudson.Lookup; -import hudson.markup.MarkupFormatter; -import hudson.Plugin; -import hudson.PluginManager; -import hudson.PluginWrapper; -import hudson.ProxyConfiguration; -import hudson.TcpSlaveAgentListener; -import hudson.UDPBroadcastThread; -import hudson.Util; -import static hudson.Util.fixEmpty; -import static hudson.Util.fixNull; -import hudson.WebAppMain; -import hudson.XmlFile; -import hudson.cli.declarative.CLIMethod; -import hudson.cli.declarative.CLIResolver; -import hudson.lifecycle.Lifecycle; -import hudson.logging.LogRecorderManager; -import hudson.lifecycle.RestartNotSupportedException; -import hudson.markup.EscapedMarkupFormatter; import hudson.remoting.Callable; import hudson.remoting.LocalChannel; import hudson.remoting.VirtualChannel; @@ -132,6 +131,7 @@ import hudson.search.SearchItem; import hudson.security.ACL; import hudson.security.AccessControlled; import hudson.security.AuthorizationStrategy; +import hudson.security.BasicAuthenticationFilter; import hudson.security.FederatedLoginService; import hudson.security.FullControlOnceLoggedInAuthorizationStrategy; import hudson.security.HudsonFilter; @@ -176,6 +176,7 @@ import hudson.util.Iterators; import hudson.util.JenkinsReloadFailed; import hudson.util.Memoizer; import hudson.util.MultipartFormDataParser; +import hudson.util.NamingThreadFactory; import hudson.util.RemotingDiagnostics; import hudson.util.RemotingDiagnostics.HeapDump; import hudson.util.StreamTaskListener; @@ -194,6 +195,7 @@ import jenkins.InitReactorRunner; import jenkins.model.ProjectNamingStrategy.DefaultProjectNamingStrategy; import jenkins.security.ConfidentialKey; import jenkins.security.ConfidentialStore; +import jenkins.security.SecurityListener; import jenkins.slaves.WorkspaceLocator; import jenkins.util.Timer; import jenkins.util.io.FileBoolean; @@ -210,11 +212,11 @@ import org.apache.commons.jelly.JellyException; import org.apache.commons.jelly.Script; import org.apache.commons.logging.LogFactory; import org.jvnet.hudson.reactor.Executable; +import org.jvnet.hudson.reactor.Reactor; import org.jvnet.hudson.reactor.ReactorException; import org.jvnet.hudson.reactor.Task; import org.jvnet.hudson.reactor.TaskBuilder; import org.jvnet.hudson.reactor.TaskGraphBuilder; -import org.jvnet.hudson.reactor.Reactor; import org.jvnet.hudson.reactor.TaskGraphBuilder.Handle; import org.kohsuke.accmod.Restricted; import org.kohsuke.accmod.restrictions.NoExternalUse; @@ -240,18 +242,15 @@ import org.kohsuke.stapler.jelly.JellyClassLoaderTearOff; import org.kohsuke.stapler.jelly.JellyRequestDispatcher; import org.xml.sax.InputSource; +import javax.annotation.CheckForNull; +import javax.annotation.Nonnull; +import javax.annotation.Nullable; import javax.crypto.SecretKey; import javax.servlet.RequestDispatcher; import javax.servlet.ServletContext; import javax.servlet.ServletException; import javax.servlet.http.Cookie; import javax.servlet.http.HttpServletResponse; - -import static hudson.init.InitMilestone.*; -import hudson.security.BasicAuthenticationFilter; -import hudson.util.NamingThreadFactory; -import static javax.servlet.http.HttpServletResponse.SC_BAD_REQUEST; -import static javax.servlet.http.HttpServletResponse.SC_NOT_FOUND; import java.io.File; import java.io.FileFilter; import java.io.IOException; @@ -291,13 +290,13 @@ import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeoutException; import java.util.concurrent.atomic.AtomicBoolean; import java.util.logging.Level; -import static java.util.logging.Level.SEVERE; import java.util.logging.LogRecord; import java.util.logging.Logger; -import javax.annotation.CheckForNull; -import javax.annotation.Nonnull; -import javax.annotation.Nullable; -import jenkins.security.SecurityListener; + +import static hudson.Util.*; +import static hudson.init.InitMilestone.*; +import static java.util.logging.Level.*; +import static javax.servlet.http.HttpServletResponse.*; /** * Root object of the system. @@ -2937,7 +2936,7 @@ public class Jenkins extends AbstractCIBase implements DirectlyModifiableTopLeve } } if (toComputer() == null) { - future.put("master", RemotingDiagnostics.getThreadDumpAsync(MasterComputer.localChannel)); + future.put("master", RemotingDiagnostics.getThreadDumpAsync(FilePath.localChannel)); } // if the result isn't available in 5 sec, ignore that. @@ -3206,7 +3205,7 @@ public class Jenkins extends AbstractCIBase implements DirectlyModifiableTopLeve * Obtains the heap dump. */ public HeapDump getHeapDump() throws IOException { - return new HeapDump(this,MasterComputer.localChannel); + return new HeapDump(this,FilePath.localChannel); } /** @@ -3413,14 +3412,14 @@ public class Jenkins extends AbstractCIBase implements DirectlyModifiableTopLeve * Run arbitrary Groovy script. */ public void doScript(StaplerRequest req, StaplerResponse rsp) throws IOException, ServletException { - _doScript(req, rsp, req.getView(this, "_script.jelly"), MasterComputer.localChannel, getACL()); + _doScript(req, rsp, req.getView(this, "_script.jelly"), FilePath.localChannel, getACL()); } /** * Run arbitrary Groovy script and return result as plain text. */ public void doScriptText(StaplerRequest req, StaplerResponse rsp) throws IOException, ServletException { - _doScript(req, rsp, req.getView(this, "_scriptText.jelly"), MasterComputer.localChannel, getACL()); + _doScript(req, rsp, req.getView(this, "_scriptText.jelly"), FilePath.localChannel, getACL()); } /** @@ -3899,7 +3898,7 @@ public class Jenkins extends AbstractCIBase implements DirectlyModifiableTopLeve @Override public VirtualChannel getChannel() { - return localChannel; + return FilePath.localChannel; } @Override @@ -3923,8 +3922,11 @@ public class Jenkins extends AbstractCIBase implements DirectlyModifiableTopLeve /** * {@link LocalChannel} instance that can be used to execute programs locally. + * + * @deprecated as of 1.558 + * Use {@link FilePath#localChannel} */ - public static final LocalChannel localChannel = new LocalChannel(threadPoolForRemoting); + public static final LocalChannel localChannel = FilePath.localChannel; } /** diff --git a/core/src/test/java/hudson/LauncherTest.java b/core/src/test/java/hudson/LauncherTest.java index 620d95ffb2..9a72701efa 100644 --- a/core/src/test/java/hudson/LauncherTest.java +++ b/core/src/test/java/hudson/LauncherTest.java @@ -24,16 +24,15 @@ package hudson; -import jenkins.model.Jenkins; import hudson.model.StreamBuildListener; import hudson.model.TaskListener; +import hudson.remoting.Callable; import hudson.util.ProcessTree; import hudson.util.StreamTaskListener; -import hudson.remoting.Callable; -import java.io.ByteArrayOutputStream; import org.apache.commons.io.FileUtils; import org.jvnet.hudson.test.Bug; +import java.io.ByteArrayOutputStream; import java.io.File; public class LauncherTest extends ChannelTestCase { @@ -97,10 +96,10 @@ public class LauncherTest extends ChannelTestCase { public void testDecoratedByEnvMaintainsIsUnix() throws Exception { ByteArrayOutputStream output = new ByteArrayOutputStream(); TaskListener listener = new StreamBuildListener(output); - Launcher remoteLauncher = new Launcher.RemoteLauncher(listener, Jenkins.MasterComputer.localChannel, false); + Launcher remoteLauncher = new Launcher.RemoteLauncher(listener, FilePath.localChannel, false); Launcher decorated = remoteLauncher.decorateByEnv(new EnvVars()); assertEquals(false, decorated.isUnix()); - remoteLauncher = new Launcher.RemoteLauncher(listener, Jenkins.MasterComputer.localChannel, true); + remoteLauncher = new Launcher.RemoteLauncher(listener, FilePath.localChannel, true); decorated = remoteLauncher.decorateByEnv(new EnvVars()); assertEquals(true, decorated.isUnix()); } @@ -109,10 +108,10 @@ public class LauncherTest extends ChannelTestCase { public void testDecoratedByPrefixMaintainsIsUnix() throws Exception { ByteArrayOutputStream output = new ByteArrayOutputStream(); TaskListener listener = new StreamBuildListener(output); - Launcher remoteLauncher = new Launcher.RemoteLauncher(listener, Jenkins.MasterComputer.localChannel, false); + Launcher remoteLauncher = new Launcher.RemoteLauncher(listener, FilePath.localChannel, false); Launcher decorated = remoteLauncher.decorateByPrefix("test"); assertEquals(false, decorated.isUnix()); - remoteLauncher = new Launcher.RemoteLauncher(listener, Jenkins.MasterComputer.localChannel, true); + remoteLauncher = new Launcher.RemoteLauncher(listener, FilePath.localChannel, true); decorated = remoteLauncher.decorateByPrefix("test"); assertEquals(true, decorated.isUnix()); }