From 256cad898045eb63036a70d90c2fc827be85fd08 Mon Sep 17 00:00:00 2001 From: Andy Wilkinson Date: Thu, 3 Dec 2015 10:57:14 +0000 Subject: [PATCH] Fix inconsistent synchronization in HttpTunnelServer.ServerThread Previously, ServerThread.lastHttpRequestTime was written while synchronized on this.httpConnections but was read without synchronization. This could lead to a read of the field producing the wrong value and cause premature connection timeout. This commit moves the call to checkNotDisconnected into a block that sychronizes on this.httpConnections, thereby ensuring that lastHttpRequestTime can be read safely. Closes gh-4668 --- .../boot/devtools/tunnel/server/HttpTunnelServer.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 829e87bf5f..fe1ee9673c 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 @@ -274,8 +274,8 @@ public class HttpTunnelServer { } private void closeStaleHttpConnections() throws IOException { - checkNotDisconnected(); synchronized (this.httpConnections) { + checkNotDisconnected(); Iterator iterator = this.httpConnections.iterator(); while (iterator.hasNext()) { HttpConnection httpConnection = iterator.next();