Avoid multiple invocations of afterConnectionClosed

This change ensures the state of a SockJS session is set to CLOSED
immediately after close is invoked. This avoids duplicate invocations
of afterConnectionClosed in WebSocket transport.

Issue: SPR-11884
master
Rossen Stoyanchev 10 years ago
parent 86de416908
commit 3af488a701
  1. 2
      spring-websocket/src/main/java/org/springframework/web/socket/sockjs/transport/session/AbstractSockJsSession.java

@ -271,6 +271,7 @@ public abstract class AbstractSockJsSession implements SockJsSession {
if (logger.isInfoEnabled()) {
logger.info("Closing SockJS session " + getId() + " with " + status);
}
this.state = State.CLOSED;
try {
if (isActive() && !CloseStatus.SESSION_NOT_RELIABLE.equals(status)) {
try {
@ -285,7 +286,6 @@ public abstract class AbstractSockJsSession implements SockJsSession {
disconnect(status);
}
finally {
this.state = State.CLOSED;
try {
this.handler.afterConnectionClosed(this, status);
}

Loading…
Cancel
Save