Skip to content
Permalink
Browse files

Update to Remoting 3.15 and Cleanup issues in Channel#current() usages (

#3145)

Pulls in fixes for: JENKINS-48133, JENKINS-48055, JENKINS-37566, JENKINS-48309, JENKINS-47965, JENKINS-48130, JENKINS-37670, JENKINS-37566, JENKINS-46724 

This change also adds some missing null/closing channel checks in the core.
In some cases the change prevents spawning threads if the channel is in the invalid state.
  • Loading branch information...
oleg-nenashev committed Dec 22, 2017
1 parent 8e78ab1 commit cb3990a4d6094260bea4571e7079fd0e3949047f
@@ -1289,6 +1289,7 @@ public Launcher getInner() {
}

public RemoteProcess call() throws IOException {
final Channel channel = getOpenChannelOrFail();
Launcher.ProcStarter ps = new LocalLauncher(listener).launch();
ps.cmds(cmd).masks(masks).envs(env).stdin(in).stdout(out).stderr(err).quiet(quiet);
if(workDir!=null) ps.pwd(workDir);
@@ -1298,16 +1299,20 @@ public RemoteProcess call() throws IOException {

final Proc p = ps.start();

return Channel.current().export(RemoteProcess.class,new RemoteProcess() {
return channel.export(RemoteProcess.class,new RemoteProcess() {
public int join() throws InterruptedException, IOException {
try {
return p.join();
} finally {
// make sure I/O is delivered to the remote before we return
Channel taskChannel = null;
try {
Channel.current().syncIO();
// Sync IO will fail automatically if the channel is being closed, no need to use getOpenChannelOrFail()
taskChannel = Channel.currentOrFail();
taskChannel.syncIO();
} catch (Throwable t) {
// this includes a failure to sync, agent.jar too old, etc
LOGGER.log(Level.INFO, "Failed to synchronize IO streams on the channel " + taskChannel, t);
}
}
}
@@ -1426,10 +1426,11 @@ public void doDumpExportTable( StaplerRequest req, StaplerResponse rsp ) throws

private static final class DumpExportTableTask extends MasterToSlaveCallable<String,IOException> {
public String call() throws IOException {
final Channel ch = getChannelOrFail();
StringWriter sw = new StringWriter();
PrintWriter pw = new PrintWriter(sw);
Channel.current().dumpExportTable(pw);
pw.close();
try (PrintWriter pw = new PrintWriter(sw)) {
ch.dumpExportTable(pw);
}
return sw.toString();
}
}
@@ -133,7 +133,8 @@ public void install(Channel channel) {

@Override
public Void call() throws IOException {
setUpPingForChannel(Channel.current(), null, pingTimeoutSeconds, pingIntervalSeconds, false);
// No sense in setting up channel pinger if the channel is being closed
setUpPingForChannel(getOpenChannelOrFail(), null, pingTimeoutSeconds, pingIntervalSeconds, false);
return null;
}

@@ -867,7 +867,7 @@ public Void call() {
// ignore this error.
}

Channel.current().setProperty("slave",Boolean.TRUE); // indicate that this side of the channel is the slave side.
Channel.currentOrFail().setProperty("slave",Boolean.TRUE); // indicate that this side of the channel is the slave side.

return null;
}
@@ -102,7 +102,7 @@ public final void uninstallFrom(Channel ch) {

/**
* Returns an {@link FilePathFilter} object that represents all the in-scope filters,
* or null if none is needed.
* or {@code null} if none is needed.
*/
public static @CheckForNull FilePathFilter current() {
Channel ch = Channel.current();
@@ -39,9 +39,7 @@ public void preOnline(Computer c, Channel channel, FilePath root, TaskListener l
private static final class ChannelSwapper extends MasterToSlaveCallable<Boolean,Exception> {
public Boolean call() throws Exception {
if (File.pathSeparatorChar==';') return false; // Windows

Channel c = Channel.current();

Channel c = getOpenChannelOrFail();
StandardOutputStream sos = (StandardOutputStream) c.getProperty(StandardOutputStream.class);
if (sos!=null) {
swap(sos);
@@ -175,7 +175,7 @@ THE SOFTWARE.
<dependency>
<groupId>org.jenkins-ci.main</groupId>
<artifactId>remoting</artifactId>
<version>3.14</version>
<version>3.15</version>
</dependency>

<dependency>
@@ -154,7 +154,7 @@ public void serviceUsingDirectSecret() throws Exception {
}
@Override
public String call() throws Exception {
return Channel.current().call(new ScriptLoader(path));
return getChannelOrFail().call(new ScriptLoader(path));
}
}

@@ -239,7 +239,7 @@ public Integer call() throws Exception {

// Invoke backward call
try {
Channel.current().call(new Callable<String, Exception>() {
getChannelOrFail().call(new Callable<String, Exception>() {
private static final long serialVersionUID = 1L;

@Override

0 comments on commit cb3990a

Please sign in to comment.
You can’t perform that action at this time.