Skip to content

Commit 3af488a

Browse files
committed
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
1 parent 86de416 commit 3af488a

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -271,6 +271,7 @@ public final void close(CloseStatus status) throws IOException {
271271
if (logger.isInfoEnabled()) {
272272
logger.info("Closing SockJS session " + getId() + " with " + status);
273273
}
274+
this.state = State.CLOSED;
274275
try {
275276
if (isActive() && !CloseStatus.SESSION_NOT_RELIABLE.equals(status)) {
276277
try {
@@ -285,7 +286,6 @@ public final void close(CloseStatus status) throws IOException {
285286
disconnect(status);
286287
}
287288
finally {
288-
this.state = State.CLOSED;
289289
try {
290290
this.handler.afterConnectionClosed(this, status);
291291
}

0 commit comments

Comments
 (0)