diff --git a/change.diff b/change.diff new file mode 100644 index 00000000000..e69de29bb2d diff --git a/spring-websocket/src/main/java/org/springframework/web/socket/sockjs/transport/session/AbstractSockJsSession.java b/spring-websocket/src/main/java/org/springframework/web/socket/sockjs/transport/session/AbstractSockJsSession.java index f2fbadeef5f..dec1b4846b4 100644 --- a/spring-websocket/src/main/java/org/springframework/web/socket/sockjs/transport/session/AbstractSockJsSession.java +++ b/spring-websocket/src/main/java/org/springframework/web/socket/sockjs/transport/session/AbstractSockJsSession.java @@ -252,6 +252,10 @@ public abstract class AbstractSockJsSession implements SockJsSession { if (isActive()) { if (heartbeatLock.tryLock()) { try { + if (this.heartbeatTask == null) { + // Cancelled while waiting to acquire the lock + return; + } writeFrame(SockJsFrame.heartbeatFrame()); scheduleHeartbeat(); }