mirror of
https://github.com/vanitasvitae/Smack.git
synced 2024-11-22 20:12:07 +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:
parent
398cba330b
commit
3b27eb520f
1 changed files with 1 additions and 2 deletions
|
@ -61,14 +61,13 @@ public abstract class AbstractSmackIntTest {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressWarnings("ThreadPriorityCheck")
|
|
||||||
protected void waitUntilTrue(Condition condition) throws TimeoutException, NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException {
|
protected void waitUntilTrue(Condition condition) throws TimeoutException, NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException {
|
||||||
final long deadline = System.currentTimeMillis() + timeout;
|
final long deadline = System.currentTimeMillis() + timeout;
|
||||||
do {
|
do {
|
||||||
if (condition.evaluate()) {
|
if (condition.evaluate()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
Thread.yield();
|
Thread.sleep(15);
|
||||||
} while (System.currentTimeMillis() <= deadline);
|
} while (System.currentTimeMillis() <= deadline);
|
||||||
throw new TimeoutException("Timeout waiting for condition to become true. Timeout was " + timeout + " ms.");
|
throw new TimeoutException("Timeout waiting for condition to become true. Timeout was " + timeout + " ms.");
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue