Polishing in WebSocketStompClient

See gh-32195
This commit is contained in:
rstoyanchev
2024-02-13 10:03:21 +00:00
parent b4153618a4
commit 6a5953dca3
2 changed files with 19 additions and 20 deletions

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2023 the original author or authors.
* Copyright 2002-2024 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -109,8 +109,7 @@ public class DefaultStompSession implements ConnectionHandlingStompSession {
private final Map<String, ReceiptHandler> receiptHandlers = new ConcurrentHashMap<>(4);
/* Whether the client is willfully closing the connection */
private volatile boolean closing;
private volatile boolean clientSideClose;
/**
@@ -368,7 +367,7 @@ public class DefaultStompSession implements ConnectionHandlingStompSession {
@Override
public void disconnect(@Nullable StompHeaders headers) {
this.closing = true;
this.clientSideClose = true;
try {
StompHeaderAccessor accessor = createHeaderAccessor(StompCommand.DISCONNECT);
if (headers != null) {
@@ -519,7 +518,7 @@ public class DefaultStompSession implements ConnectionHandlingStompSession {
if (logger.isDebugEnabled()) {
logger.debug("Connection closed in session id=" + this.sessionId);
}
if (!this.closing) {
if (!this.clientSideClose) {
resetConnection();
handleFailure(new ConnectionLostException("Connection closed"));
}
@@ -729,11 +728,11 @@ public class DefaultStompSession implements ConnectionHandlingStompSession {
@Override
public void run() {
closing = true;
String error = "Server has gone quiet. Closing connection in session id=" + sessionId + ".";
String error = "Read inactivity. Closing connection in session id=" + sessionId + ".";
if (logger.isDebugEnabled()) {
logger.debug(error);
}
clientSideClose = true;
resetConnection();
handleFailure(new IllegalStateException(error));
}