From 977b67e418d8ffde04c88f1b416599372fcfad94 Mon Sep 17 00:00:00 2001 From: Rossen Stoyanchev Date: Mon, 8 Aug 2016 17:33:57 -0400 Subject: [PATCH] Protect sendHeartbeat from cancellation Issue: SPR-14564 --- change.diff | 0 .../sockjs/transport/session/AbstractSockJsSession.java | 4 ++++ 2 files changed, 4 insertions(+) create mode 100644 change.diff diff --git a/change.diff b/change.diff new file mode 100644 index 0000000000..e69de29bb2 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 f2fbadeef5..dec1b4846b 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(); }