mirror of https://github.com/apache/activemq.git
Resolve race that leads to stalled connect attempt. Should fix the failing CI tests that are seeing this.
This commit is contained in:
parent
87fd0a9e05
commit
10ae0d9d6f
|
@ -34,7 +34,7 @@ import org.fusesource.mqtt.codec.MQTTFrame;
|
|||
|
||||
public abstract class AbstractMQTTSocket extends TransportSupport implements MQTTTransport, BrokerServiceAware {
|
||||
|
||||
protected MQTTProtocolConverter protocolConverter = null;
|
||||
protected volatile MQTTProtocolConverter protocolConverter = null;
|
||||
protected MQTTWireFormat wireFormat = new MQTTWireFormat();
|
||||
protected final MQTTInactivityMonitor mqttInactivityMonitor = new MQTTInactivityMonitor(this, wireFormat);
|
||||
protected final CountDownLatch socketTransportStarted = new CountDownLatch(1);
|
||||
|
@ -123,7 +123,11 @@ public abstract class AbstractMQTTSocket extends TransportSupport implements MQT
|
|||
|
||||
protected MQTTProtocolConverter getProtocolConverter() {
|
||||
if (protocolConverter == null) {
|
||||
protocolConverter = new MQTTProtocolConverter(this, brokerService);
|
||||
synchronized(this) {
|
||||
if (protocolConverter == null) {
|
||||
protocolConverter = new MQTTProtocolConverter(this, brokerService);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return protocolConverter;
|
||||
|
|
|
@ -72,6 +72,20 @@ public class MQTTWSTransportTest extends WSTransportTestSupport {
|
|||
super.tearDown();
|
||||
}
|
||||
|
||||
@Test(timeout = 60000)
|
||||
public void testConnectCycles() throws Exception {
|
||||
for (int i = 0; i < 10; ++i) {
|
||||
testConnect();
|
||||
|
||||
wsMQTTConnection = new MQTTWSConnection();
|
||||
|
||||
wsClient.open(wsConnectUri, wsMQTTConnection);
|
||||
if (!wsMQTTConnection.awaitConnection(30, TimeUnit.SECONDS)) {
|
||||
throw new IOException("Could not connect to MQTT WS endpoint");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Test(timeout = 60000)
|
||||
public void testConnect() throws Exception {
|
||||
|
||||
|
|
Loading…
Reference in New Issue