SubProtocolWebSocketHandler closes sessions outside of lifecycle monitor
Issue: SPR-16488
This commit is contained in:
parent
a5a069c5b1
commit
3c631f8ea0
|
|
@ -245,6 +245,7 @@ public class SubProtocolWebSocketHandler
|
||||||
@Override
|
@Override
|
||||||
public final void start() {
|
public final void start() {
|
||||||
Assert.isTrue(this.defaultProtocolHandler != null || !this.protocolHandlers.isEmpty(), "No handlers");
|
Assert.isTrue(this.defaultProtocolHandler != null || !this.protocolHandlers.isEmpty(), "No handlers");
|
||||||
|
|
||||||
synchronized (this.lifecycleMonitor) {
|
synchronized (this.lifecycleMonitor) {
|
||||||
this.clientOutboundChannel.subscribe(this);
|
this.clientOutboundChannel.subscribe(this);
|
||||||
this.running = true;
|
this.running = true;
|
||||||
|
|
@ -256,6 +257,9 @@ public class SubProtocolWebSocketHandler
|
||||||
synchronized (this.lifecycleMonitor) {
|
synchronized (this.lifecycleMonitor) {
|
||||||
this.running = false;
|
this.running = false;
|
||||||
this.clientOutboundChannel.unsubscribe(this);
|
this.clientOutboundChannel.unsubscribe(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Proactively notify all active WebSocket sessions
|
||||||
for (WebSocketSessionHolder holder : this.sessions.values()) {
|
for (WebSocketSessionHolder holder : this.sessions.values()) {
|
||||||
try {
|
try {
|
||||||
holder.getSession().close(CloseStatus.GOING_AWAY);
|
holder.getSession().close(CloseStatus.GOING_AWAY);
|
||||||
|
|
@ -267,7 +271,6 @@ public class SubProtocolWebSocketHandler
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public final void stop(Runnable callback) {
|
public final void stop(Runnable callback) {
|
||||||
|
|
@ -291,6 +294,7 @@ public class SubProtocolWebSocketHandler
|
||||||
if (!session.isOpen()) {
|
if (!session.isOpen()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
this.stats.incrementSessionCount(session);
|
this.stats.incrementSessionCount(session);
|
||||||
session = decorateSession(session);
|
session = decorateSession(session);
|
||||||
this.sessions.put(session.getId(), new WebSocketSessionHolder(session));
|
this.sessions.put(session.getId(), new WebSocketSessionHolder(session));
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue