提交 9fc59bf2 编写于 作者: J Jesse Glick

Finally figured out how to suppress the ReadPendingException from Jetty.

Something¹ seems to interrupt the HTTP duplex service thread,
and Jetty apparently deals poorly with interruptions.
So introduce an extra sleep to soak up the interrupt.

¹Who? http://stackoverflow.com/questions/2126997/who-is-calling-the-java-thread-interrupt-method-if-im-not#comment40865453_2127397
上级 5caee586
......@@ -135,12 +135,12 @@ class PlainCLIProtocol {
}
} catch (ClosedChannelException x) {
LOGGER.log(Level.FINE, null, x);
handleClose();
} catch (IOException x) {
LOGGER.log(Level.WARNING, null, flightRecorder.analyzeCrash(x, "broken stream"));
} catch (ReadPendingException x) {
// in case trick in CLIAction does not work
LOGGER.log(Level.FINE, null, x);
// TODO what does this signify? Seems to be thrown randomly by org.eclipse.jetty.io.FillInterest.register. No obvious impact.
// Contrary to https://github.com/eclipse/jetty.project/issues/1047 this still happens in 9.4.3.v20170317 as in https://github.com/joakime/jetty-async-bug/issues/1
handleClose();
}
}
......
......@@ -221,6 +221,11 @@ public class CLIAction implements UnprotectedRootAction, StaplerProxy {
int exit = command.main(connection.args.subList(1, connection.args.size()), connection.locale, connection.stdin, stdout, stderr);
stdout.flush();
connection.sendExit(exit);
try { // seems to avoid ReadPendingException from Jetty
Thread.sleep(1000);
} catch (InterruptedException x) {
// expected; ignore
}
} finally {
CLICommand.setCurrent(orig);
runningThread.set(null);
......
......@@ -27,6 +27,7 @@ import java.util.UUID;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.TimeUnit;
import java.util.logging.Level;
import jenkins.model.Jenkins;
import jenkins.security.ApiTokenProperty;
import jenkins.util.Timer;
......@@ -39,6 +40,7 @@ import org.junit.Test;
import org.junit.rules.TemporaryFolder;
import org.jvnet.hudson.test.Issue;
import org.jvnet.hudson.test.JenkinsRule;
import org.jvnet.hudson.test.LoggerRule;
import org.jvnet.hudson.test.MockAuthorizationStrategy;
import org.jvnet.hudson.test.TestExtension;
import org.jvnet.hudson.test.recipes.PresetData;
......@@ -54,6 +56,9 @@ public class CLIActionTest {
@Rule
public TemporaryFolder tmp = new TemporaryFolder();
@Rule
public LoggerRule logging = new LoggerRule();
private ExecutorService pool;
/**
......@@ -131,6 +136,7 @@ public class CLIActionTest {
@Issue({"JENKINS-12543", "JENKINS-41745"})
@Test
public void authentication() throws Exception {
logging.record(PlainCLIProtocol.class, Level.FINE);
File jar = tmp.newFile("jenkins-cli.jar");
FileUtils.copyURLToFile(j.jenkins.getJnlpJars("jenkins-cli.jar").getURL(), jar);
j.jenkins.setSecurityRealm(j.createDummySecurityRealm());
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册