From 3b27eb520feec0051b27ee93d8b70f6b6ce04f37 Mon Sep 17 00:00:00 2001 From: Florian Schmaus Date: Tue, 7 Apr 2020 16:58:21 +0200 Subject: [PATCH] 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. --- .../org/igniterealtime/smack/inttest/AbstractSmackIntTest.java | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/smack-integration-test/src/main/java/org/igniterealtime/smack/inttest/AbstractSmackIntTest.java b/smack-integration-test/src/main/java/org/igniterealtime/smack/inttest/AbstractSmackIntTest.java index 57b85f722..2bdb340bd 100644 --- a/smack-integration-test/src/main/java/org/igniterealtime/smack/inttest/AbstractSmackIntTest.java +++ b/smack-integration-test/src/main/java/org/igniterealtime/smack/inttest/AbstractSmackIntTest.java @@ -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."); }