Skip to content

Commit 977b67e

Browse files
committed
Protect sendHeartbeat from cancellation
Issue: SPR-14564
1 parent 5c85732 commit 977b67e

File tree

2 files changed

+4
-0
lines changed

2 files changed

+4
-0
lines changed

change.diff

Whitespace-only changes.

spring-websocket/src/main/java/org/springframework/web/socket/sockjs/transport/session/AbstractSockJsSession.java

+4
Original file line numberDiff line numberDiff line change
@@ -252,6 +252,10 @@ public void sendHeartbeat() throws SockJsTransportFailureException {
252252
if (isActive()) {
253253
if (heartbeatLock.tryLock()) {
254254
try {
255+
if (this.heartbeatTask == null) {
256+
// Cancelled while waiting to acquire the lock
257+
return;
258+
}
255259
writeFrame(SockJsFrame.heartbeatFrame());
256260
scheduleHeartbeat();
257261
}

0 commit comments

Comments
 (0)