Harden synchronization around SockJS heartbeats
Create an explicit heartbeat task with an experiration flag so that it can be cancelled reliably vs relying on the ScheduledFutureTask cancel method which may return true even if the task is already running. Issue: SPR-14356
This commit is contained in:
@@ -270,6 +270,7 @@ public class SockJsSessionTests extends AbstractSockJsSessionTests<TestSockJsSes
|
||||
@Test
|
||||
public void sendHeartbeatWhenDisabled() throws Exception {
|
||||
this.session.disableHeartbeat();
|
||||
this.session.setActive(true);
|
||||
this.session.sendHeartbeat();
|
||||
|
||||
assertEquals(Collections.emptyList(), this.session.getSockJsFramesWritten());
|
||||
@@ -292,7 +293,6 @@ public class SockJsSessionTests extends AbstractSockJsSessionTests<TestSockJsSes
|
||||
|
||||
this.session.cancelHeartbeat();
|
||||
|
||||
verify(task).isCancelled();
|
||||
verify(task).cancel(false);
|
||||
verifyNoMoreInteractions(task);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user