Skip to content

Commit

Permalink
[FIXED JENKINS-46659] Avoid Jetty timeouts by sending a ping-like pac…
Browse files Browse the repository at this point in the history
…ket every 10s while a CLI command is running.

(cherry picked from commit dc06c3f)
  • Loading branch information
jglick authored and olivergondza committed Oct 23, 2017
1 parent 06b0cd6 commit dda5903
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 8 deletions.
16 changes: 16 additions & 0 deletions cli/src/main/java/hudson/cli/CLI.java
Expand Up @@ -704,6 +704,22 @@ public void run() {
}
}
}.start();
new Thread("ping") { // JENKINS-46659
@Override
public void run() {
try {
Thread.sleep(10_000);
while (!connection.complete) {
LOGGER.fine("sending ping");
connection.sendEncoding(Charset.defaultCharset().name()); // no-op at this point
Thread.sleep(10_000);
}
} catch (IOException | InterruptedException x) {
LOGGER.log(Level.WARNING, null, x);
}
}

}.start();
synchronized (connection) {
while (!connection.complete) {
connection.wait();
Expand Down
8 changes: 0 additions & 8 deletions cli/src/main/java/hudson/cli/PlainCLIProtocol.java
Expand Up @@ -34,7 +34,6 @@
import java.io.OutputStream;
import java.nio.channels.ClosedChannelException;
import java.nio.channels.ReadPendingException;
import java.util.concurrent.TimeoutException;
import java.util.logging.Level;
import java.util.logging.Logger;
import org.apache.commons.io.IOUtils;
Expand Down Expand Up @@ -112,13 +111,6 @@ public void run() {
} catch (EOFException x) {
handleClose();
break; // TODO verify that we hit EOF immediately, not partway into framelen
} catch (IOException x) {
if (x.getCause() instanceof TimeoutException) { // TODO on Tomcat this seems to be SocketTimeoutException
LOGGER.log(Level.FINE, "ignoring idle timeout, perhaps from Jetty", x);
continue;
} else {
throw x;
}
}
if (framelen < 0) {
throw new IOException("corrupt stream: negative frame length");
Expand Down

0 comments on commit dda5903

Please sign in to comment.