Fixing an intermittent test failure in:

org.apache.activemq.transport.ws.StompWSSTransportTest.
testHeartbeatsKeepsConnectionOpen

Adding synchronization on sends for StompWSConnection.  The protocol
doesn't allow multiple threads to call a blocking send at the same time
and the heartbeat keep alive thread was colliding with the main
thread on sends.
This commit is contained in:
Christopher L. Shannon (cshannon) 2015-11-22 19:01:31 +00:00
parent de5d0d9430
commit bbde8473bd
1 changed files with 3 additions and 3 deletions

View File

@ -57,17 +57,17 @@ public class StompWSConnection extends WebSocketAdapter implements WebSocketList
//---- Send methods ------------------------------------------------------// //---- Send methods ------------------------------------------------------//
public void sendRawFrame(String rawFrame) throws Exception { public synchronized void sendRawFrame(String rawFrame) throws Exception {
checkConnected(); checkConnected();
connection.getRemote().sendString(rawFrame); connection.getRemote().sendString(rawFrame);
} }
public void sendFrame(StompFrame frame) throws Exception { public synchronized void sendFrame(StompFrame frame) throws Exception {
checkConnected(); checkConnected();
connection.getRemote().sendString(frame.format()); connection.getRemote().sendString(frame.format());
} }
public void keepAlive() throws Exception { public synchronized void keepAlive() throws Exception {
checkConnected(); checkConnected();
connection.getRemote().sendString("\n"); connection.getRemote().sendString("\n");
} }