From df9308c645ea121f20ae03e34a96a65640e10e40 Mon Sep 17 00:00:00 2001 From: Andy Wilkinson Date: Fri, 4 Dec 2015 16:00:25 +0000 Subject: [PATCH] HttpTunnelServer should only check for disconnect after first connection MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Previously, ServerThread would check for a disconnect as soon as it had been started. This raced with it handling its first connection. If the check for disconnect won the race it would incorrectly determine that the disconnect timeout had been reached and wouldn’t respond to the connection. This commit updates ServerThread so that it only checks the disconnect timeout once it’s handled at least one connection. Closes gh-4668 --- .../boot/devtools/tunnel/server/HttpTunnelServer.java | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/spring-boot-devtools/src/main/java/org/springframework/boot/devtools/tunnel/server/HttpTunnelServer.java b/spring-boot-devtools/src/main/java/org/springframework/boot/devtools/tunnel/server/HttpTunnelServer.java index fe1ee9673c..c1bfae52a5 100644 --- a/spring-boot-devtools/src/main/java/org/springframework/boot/devtools/tunnel/server/HttpTunnelServer.java +++ b/spring-boot-devtools/src/main/java/org/springframework/boot/devtools/tunnel/server/HttpTunnelServer.java @@ -289,9 +289,12 @@ public class HttpTunnelServer { } private void checkNotDisconnected() { - long timeout = HttpTunnelServer.this.disconnectTimeout; - long duration = System.currentTimeMillis() - this.lastHttpRequestTime; - Assert.state(duration < timeout, "Disconnect timeout"); + if (this.lastHttpRequestTime > 0) { + long timeout = HttpTunnelServer.this.disconnectTimeout; + long duration = System.currentTimeMillis() - this.lastHttpRequestTime; + Assert.state(duration < timeout, + "Disconnect timeout: " + timeout + " " + duration); + } } private void closeHttpConnections() {