From 7263e820f3eba3271d03feb890635dbbe2d5d6ef Mon Sep 17 00:00:00 2001 From: Clebert Suconic Date: Thu, 5 Sep 2019 11:05:35 -0400 Subject: [PATCH] NO-JIRA Fixing intermittent failure on CreditsSemaphoreTest --- .../artemis/protocol/amqp/util/CreditsSemaphoreTest.java | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/artemis-protocols/artemis-amqp-protocol/src/test/java/org/apache/activemq/artemis/protocol/amqp/util/CreditsSemaphoreTest.java b/artemis-protocols/artemis-amqp-protocol/src/test/java/org/apache/activemq/artemis/protocol/amqp/util/CreditsSemaphoreTest.java index f795fa5ab2..d4e7805661 100644 --- a/artemis-protocols/artemis-amqp-protocol/src/test/java/org/apache/activemq/artemis/protocol/amqp/util/CreditsSemaphoreTest.java +++ b/artemis-protocols/artemis-amqp-protocol/src/test/java/org/apache/activemq/artemis/protocol/amqp/util/CreditsSemaphoreTest.java @@ -85,12 +85,14 @@ public class CreditsSemaphoreTest { Assert.assertEquals(0, semaphore.getCredits()); - long timeout = System.currentTimeMillis() + 1000; - while (!semaphore.hasQueuedThreads() && System.currentTimeMillis() < timeout) { + // TODO: Wait.assertTrue is not available at this package. So, this is making what we would be doing with a Wait Clause + // we could replace this next block with a Wait clause on hasQueuedThreads + int i = 0; + for (i = 0; i < 1000 && !semaphore.hasQueuedThreads(); i++) { Thread.sleep(10); } - Assert.assertTrue(semaphore.hasQueuedThreads()); + Assert.assertTrue(i < 1000); semaphore.release(2);