Catch exception while clearing TCP conn to broker

When a DISCONNECT is sent to the broker, we proactively close the TCP
connection unless the DISCONNECT has a receipt header. Depending on
the timing, the broker may also close the connection on its side.
That appears to cause an exception in reactor on the CI server, e.g.:

https://build.spring.io/browse/SPR-PUB-JOB1-1715/test/case/135247530

This change traps the exceptions and prevents it from propagating.
master
Rossen Stoyanchev 10 years ago
parent 5444c35777
commit 6c57c3e4b5
  1. 12
      spring-messaging/src/main/java/org/springframework/messaging/simp/stomp/StompBrokerRelayMessageHandler.java

@ -552,9 +552,8 @@ public class StompBrokerRelayMessageHandler extends AbstractBrokerMessageHandler
clearConnection(); clearConnection();
} }
catch (Throwable ex2) { catch (Throwable ex2) {
if (logger.isErrorEnabled()) { if (logger.isDebugEnabled()) {
logger.error("Failure while cleaning up state for TCP connection in session " + logger.debug("Failure while clearing TCP connection state in session " + this.sessionId, ex2);
this.sessionId, ex2);
} }
} }
} }
@ -771,8 +770,15 @@ public class StompBrokerRelayMessageHandler extends AbstractBrokerMessageHandler
*/ */
private void afterDisconnectSent(StompHeaderAccessor accessor) { private void afterDisconnectSent(StompHeaderAccessor accessor) {
if (accessor.getReceipt() == null) { if (accessor.getReceipt() == null) {
try {
clearConnection(); clearConnection();
} }
catch (Throwable ex) {
if (logger.isDebugEnabled()) {
logger.debug("Failure while clearing TCP connection state in session " + this.sessionId, ex);
}
}
}
} }
/** /**

Loading…
Cancel
Save