You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@activemq.apache.org by ta...@apache.org on 2015/06/30 23:16:55 UTC
activemq git commit: https://issues.apache.org/jira/browse/AMQ-5870
Repository: activemq
Updated Branches:
refs/heads/master 87fd0a9e0 -> 10ae0d9d6
https://issues.apache.org/jira/browse/AMQ-5870
Resolve race that leads to stalled connect attempt. Should fix the
failing CI tests that are seeing this.
Project: http://git-wip-us.apache.org/repos/asf/activemq/repo
Commit: http://git-wip-us.apache.org/repos/asf/activemq/commit/10ae0d9d
Tree: http://git-wip-us.apache.org/repos/asf/activemq/tree/10ae0d9d
Diff: http://git-wip-us.apache.org/repos/asf/activemq/diff/10ae0d9d
Branch: refs/heads/master
Commit: 10ae0d9d6fa985dbfc55dbf8a2d8271622e44e39
Parents: 87fd0a9
Author: Timothy Bish <ta...@gmail.com>
Authored: Tue Jun 30 17:16:47 2015 -0400
Committer: Timothy Bish <ta...@gmail.com>
Committed: Tue Jun 30 17:16:47 2015 -0400
----------------------------------------------------------------------
.../activemq/transport/ws/AbstractMQTTSocket.java | 8 ++++++--
.../activemq/transport/ws/MQTTWSTransportTest.java | 14 ++++++++++++++
2 files changed, 20 insertions(+), 2 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/activemq/blob/10ae0d9d/activemq-http/src/main/java/org/apache/activemq/transport/ws/AbstractMQTTSocket.java
----------------------------------------------------------------------
diff --git a/activemq-http/src/main/java/org/apache/activemq/transport/ws/AbstractMQTTSocket.java b/activemq-http/src/main/java/org/apache/activemq/transport/ws/AbstractMQTTSocket.java
index 5f67d8a..21c8f5e 100644
--- a/activemq-http/src/main/java/org/apache/activemq/transport/ws/AbstractMQTTSocket.java
+++ b/activemq-http/src/main/java/org/apache/activemq/transport/ws/AbstractMQTTSocket.java
@@ -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;
http://git-wip-us.apache.org/repos/asf/activemq/blob/10ae0d9d/activemq-http/src/test/java/org/apache/activemq/transport/ws/MQTTWSTransportTest.java
----------------------------------------------------------------------
diff --git a/activemq-http/src/test/java/org/apache/activemq/transport/ws/MQTTWSTransportTest.java b/activemq-http/src/test/java/org/apache/activemq/transport/ws/MQTTWSTransportTest.java
index f304ada..b62442a 100644
--- a/activemq-http/src/test/java/org/apache/activemq/transport/ws/MQTTWSTransportTest.java
+++ b/activemq-http/src/test/java/org/apache/activemq/transport/ws/MQTTWSTransportTest.java
@@ -73,6 +73,20 @@ public class MQTTWSTransportTest extends WSTransportTestSupport {
}
@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 {
wsMQTTConnection.connect();