Skip to content

Commit 127fe1d

Browse files
author
Ian Craggs
committed
Ensure threads in test330 have terminated
1 parent 576455e commit 127fe1d

1 file changed

Lines changed: 13 additions & 1 deletion

File tree

  • org.eclipse.paho.client.mqttv3.test/src/test/java/org/eclipse/paho/client/mqttv3/test

org.eclipse.paho.client.mqttv3.test/src/test/java/org/eclipse/paho/client/mqttv3/test/BasicTest.java

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -335,6 +335,7 @@ public void test330() throws Exception {
335335
String methodName = Utility.getMethodName();
336336
LoggingUtilities.banner(log, cclass, methodName);
337337

338+
int before_thread_count = Thread.activeCount();
338339
URI uri = new URI("tcp://iot.eclipse.org:1882");
339340
IMqttAsyncClient client = clientFactory.createMqttAsyncClient(uri, "client-1");
340341

@@ -353,6 +354,17 @@ public void test330() throws Exception {
353354
} finally {
354355
client.close();
355356
}
357+
358+
int after_count = Thread.activeCount();
359+
Thread[] tarray = new Thread[after_count];
360+
while (after_count > before_thread_count) {
361+
after_count = Thread.enumerate(tarray);
362+
for (int i = 0; i < after_count; ++i) {
363+
log.info(i + " " + tarray[i].getName());
364+
}
365+
Thread.sleep(100);
366+
}
367+
Assert.assertEquals(before_thread_count, after_count);
356368
}
357369

358370

@@ -465,7 +477,7 @@ public void test402a() throws Exception {
465477
for (int i = 0; i < after_count; ++i) {
466478
log.info(i + " " + tarray[i].getName());
467479
}
468-
Assert.assertEquals(before_thread_count, after_count - pool_size);
480+
Assert.assertEquals(after_count, before_thread_count + pool_size);
469481
}
470482

471483

0 commit comments

Comments
 (0)