1
0
Fork 0
mirror of https://codeberg.org/Mercury-IM/Smack synced 2024-12-22 20:47:57 +01:00

sinttest: Use Thread.sleep(15) instead of Thread.yield()

Guus reports that the entity caps sinttest fails on openfire with an
timeout exception on Java 11. Very well possible that this is caused
by a changed scheduling behavior where the yield() thread nevertheless
dominates the, potential single, core.

The waitUntilThread() method is essentially a broken approach anyway
and should be replaced in the future.
This commit is contained in:
Florian Schmaus 2020-04-07 16:58:21 +02:00
parent 398cba330b
commit 3b27eb520f

View file

@ -61,14 +61,13 @@ public abstract class AbstractSmackIntTest {
}
}
@SuppressWarnings("ThreadPriorityCheck")
protected void waitUntilTrue(Condition condition) throws TimeoutException, NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException {
final long deadline = System.currentTimeMillis() + timeout;
do {
if (condition.evaluate()) {
return;
}
Thread.yield();
Thread.sleep(15);
} while (System.currentTimeMillis() <= deadline);
throw new TimeoutException("Timeout waiting for condition to become true. Timeout was " + timeout + " ms.");
}