From 6c57c3e4b56b37254b6a3cc101343eb366cd2158 Mon Sep 17 00:00:00 2001 From: Rossen Stoyanchev Date: Fri, 26 Sep 2014 12:03:54 -0400 Subject: [PATCH] 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. --- .../simp/stomp/StompBrokerRelayMessageHandler.java | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/spring-messaging/src/main/java/org/springframework/messaging/simp/stomp/StompBrokerRelayMessageHandler.java b/spring-messaging/src/main/java/org/springframework/messaging/simp/stomp/StompBrokerRelayMessageHandler.java index e4430dee70..57695407d3 100644 --- a/spring-messaging/src/main/java/org/springframework/messaging/simp/stomp/StompBrokerRelayMessageHandler.java +++ b/spring-messaging/src/main/java/org/springframework/messaging/simp/stomp/StompBrokerRelayMessageHandler.java @@ -552,9 +552,8 @@ public class StompBrokerRelayMessageHandler extends AbstractBrokerMessageHandler clearConnection(); } catch (Throwable ex2) { - if (logger.isErrorEnabled()) { - logger.error("Failure while cleaning up state for TCP connection in session " + - this.sessionId, ex2); + if (logger.isDebugEnabled()) { + logger.debug("Failure while clearing TCP connection state in session " + this.sessionId, ex2); } } } @@ -771,7 +770,14 @@ public class StompBrokerRelayMessageHandler extends AbstractBrokerMessageHandler */ private void afterDisconnectSent(StompHeaderAccessor accessor) { if (accessor.getReceipt() == null) { - clearConnection(); + try { + clearConnection(); + } + catch (Throwable ex) { + if (logger.isDebugEnabled()) { + logger.debug("Failure while clearing TCP connection state in session " + this.sessionId, ex); + } + } } }