Skip to content

Commit 3365f91

Browse files
committed
Fix flaky MQTT Java test
Every ~30 runs, test case `sessionRedelivery` was failing with error: ``` [ERROR] sessionRedelivery{TestInfo} Time elapsed: 1.298 s <<< ERROR! org.eclipse.paho.client.mqttv3.MqttException: Client is currently disconnecting at com.rabbitmq.mqtt.test.MqttTest.sessionRedelivery(MqttTest.java:535) ``` The problem was that the Java client was still in connection state `DISCONNECTING` which throws a Java exception when `connect()`ing. So, the problem was client side. We already check for `isConnected()` to be `false` which internally checks for ``` conState == CONNECTED ``` However, there is no public client API to check for other connection states. Therefore just waiting for a few milliseconds fixes the flake. (cherry picked from commit 2dc45e8)
1 parent 9099e26 commit 3365f91

File tree

1 file changed

+2
-0
lines changed
  • deps/rabbitmq_mqtt/test/java_SUITE_data/src/test/java/com/rabbitmq/mqtt/test

1 file changed

+2
-0
lines changed

deps/rabbitmq_mqtt/test/java_SUITE_data/src/test/java/com/rabbitmq/mqtt/test/MqttTest.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -532,6 +532,8 @@ protected void testQueuePropertiesWithCleanSession(boolean cleanSession, String
532532
failOnDelivery = false;
533533

534534
client.setCallback(this);
535+
// Wait for client to leave connection state 'DISCONNECTING'.
536+
Thread.sleep(500);
535537
client.connect(client_opts);
536538

537539
// Message has been redelivered after session resume

0 commit comments

Comments
 (0)