提交 4378e878 编写于 作者: K Kohsuke Kawaguchi

[FIXED JENKINS-12680] the onOffline method wasn't called for abrupt client termination

上级 482b4333
......@@ -93,7 +93,10 @@ Upcoming changes</a>
<li class=bug>
Fixed a bug in LDAP default root DN inference.
(<a href="https://issues.jenkins-ci.org/browse/JENKINS-8152">issue 8152</a>)
<li class=rfe>
<li class=bug>
<tt>ComputerListener.onOffline</tt> was not called when the client was terminated abruptly.
(<a href="https://issues.jenkins-ci.org/browse/JENKINS-12680">issue 12680</a>)
<li class=ref>
CLI now supports also encrypted key file
<li class=rfe>
Recognize test results from eviware:maven-soapui-plugin.
......
......@@ -329,14 +329,14 @@ public class SlaveComputer extends Computer {
channel.addListener(new Channel.Listener() {
@Override
public void onClosed(Channel c, IOException cause) {
SlaveComputer.this.channel = null;
// Orderly shutdown will have null exception
if (cause!=null) {
offlineCause = new ChannelTermination(cause);
cause.printStackTrace(taskListener.error("Connection terminated"));
cause.printStackTrace(taskListener.error("Connection terminated"));
} else {
taskListener.getLogger().println("Connection terminated");
}
closeChannel();
launcher.afterDisconnect(SlaveComputer.this, taskListener);
}
});
......@@ -501,9 +501,9 @@ public class SlaveComputer extends Computer {
} catch (IOException e) {
logger.log(Level.SEVERE, "Failed to terminate channel to " + getDisplayName(), e);
}
for (ComputerListener cl : ComputerListener.all())
cl.onOffline(this);
}
for (ComputerListener cl : ComputerListener.all())
cl.onOffline(this);
}
@Override
......
......@@ -31,13 +31,17 @@ import hudson.model.Computer;
import hudson.model.Node;
import hudson.model.Node.Mode;
import hudson.model.Slave;
import hudson.model.TaskListener;
import hudson.remoting.Callable;
import hudson.remoting.Which;
import hudson.util.ArgumentListBuilder;
import org.jvnet.hudson.test.HudsonTestCase;
import org.jvnet.hudson.test.TestExtension;
import javax.inject.Inject;
import java.io.File;
import java.io.IOException;
import java.net.URL;
import java.util.ArrayList;
import java.util.List;
......@@ -69,8 +73,22 @@ public class JNLPLauncherTest extends HudsonTestCase {
public void testHeadlessLaunch() throws Exception {
Computer c = addTestSlave();
launchJnlpAndVerify(c, buildJnlpArgs(c).add("-arg","-headless"));
// make sure that onOffline gets called just the right number of times
assertEquals(1, ComputerListener.all().get(ListenerImpl.class).offlined);
}
@TestExtension
public static class ListenerImpl extends ComputerListener {
int offlined = 0;
@Override
public void onOffline(Computer c) {
offlined++;
assertTrue(c.isOffline());
}
}
private ArgumentListBuilder buildJnlpArgs(Computer c) throws Exception {
ArgumentListBuilder args = new ArgumentListBuilder();
args.add(new File(new File(System.getProperty("java.home")),"bin/java").getPath(),"-jar");
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册