NO-JIRA Allow for the disconnect call in the test to fail as the short

keepAlive interval can trigger a shutdown of the socket before we have a
chance to write the disconnect depending on the timing.
This commit is contained in:
Timothy Bish 2016-03-17 14:08:09 -04:00
parent 2788bd5584
commit 30d6ad72fa
3 changed files with 8 additions and 4 deletions

View File

@ -80,7 +80,7 @@ public class MQTTSocket extends AbstractMQTTSocket implements WebSocketListener
try {
getProtocolConverter().onMQTTCommand(new DISCONNECT().encode());
} catch (Exception e) {
LOG.warn("Failed to close WebSocket", e);
LOG.debug("Failed to close MQTT WebSocket cleanly", e);
}
}

View File

@ -64,11 +64,11 @@ public class StompSocket extends AbstractStompSocket implements WebSocketListene
public void onWebSocketClose(int arg0, String arg1) {
try {
if (protocolLock.tryLock() || protocolLock.tryLock(ORDERLY_CLOSE_TIMEOUT, TimeUnit.SECONDS)) {
LOG.info("Stomp WebSocket closed: code[{}] message[{}]", arg0, arg1);
LOG.debug("Stomp WebSocket closed: code[{}] message[{}]", arg0, arg1);
protocolConverter.onStompCommand(new StompFrame(Stomp.Commands.DISCONNECT));
}
} catch (Exception e) {
LOG.warn("Failed to close WebSocket", e);
LOG.debug("Failed to close STOMP WebSocket cleanly", e);
} finally {
if (protocolLock.isHeldByCurrentThread()) {
protocolLock.unlock();

View File

@ -283,6 +283,10 @@ public class StompWSTransportTest extends WSTransportTestSupport {
service.shutdownNow();
service.awaitTermination(5, TimeUnit.SECONDS);
wsStompConnection.sendFrame(new StompFrame(Stomp.Commands.DISCONNECT));
try {
wsStompConnection.sendFrame(new StompFrame(Stomp.Commands.DISCONNECT));
} catch (Exception ex) {
LOG.info("Caught exception on write of disconnect", ex);
}
}
}