Fix randomly failing test
Project: http://git-wip-us.apache.org/repos/asf/cxf/repo Commit: http://git-wip-us.apache.org/repos/asf/cxf/commit/8592c87e Tree: http://git-wip-us.apache.org/repos/asf/cxf/tree/8592c87e Diff: http://git-wip-us.apache.org/repos/asf/cxf/diff/8592c87e Branch: refs/heads/master Commit: 8592c87e5d004b36899a980545bec4c82ecdef26 Parents: e3abb5e Author: Daniel Kulp <dk...@apache.org> Authored: Fri Aug 18 15:00:47 2017 -0400 Committer: Daniel Kulp <dk...@apache.org> Committed: Fri Aug 18 15:28:36 2017 -0400 ---------------------------------------------------------------------- .../org/apache/cxf/workqueue/AutomaticWorkQueueTest.java | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/cxf/blob/8592c87e/core/src/test/java/org/apache/cxf/workqueue/AutomaticWorkQueueTest.java ---------------------------------------------------------------------- diff --git a/core/src/test/java/org/apache/cxf/workqueue/AutomaticWorkQueueTest.java b/core/src/test/java/org/apache/cxf/workqueue/AutomaticWorkQueueTest.java index 38e5884..4ce358d 100644 --- a/core/src/test/java/org/apache/cxf/workqueue/AutomaticWorkQueueTest.java +++ b/core/src/test/java/org/apache/cxf/workqueue/AutomaticWorkQueueTest.java @@ -179,13 +179,18 @@ public class AutomaticWorkQueueTest extends Assert { } } - while (workqueue.getActiveCount() < DEFAULT_HIGH_WATER_MARK) { + int max = 0; + while (workqueue.getActiveCount() < DEFAULT_HIGH_WATER_MARK + && workqueue.getSize() > 0 + && max < 10) { try { - Thread.sleep(250); + //wait up to a second for all the threads to start and grab items + Thread.sleep(100); + max++; } catch (InterruptedException ex) { // ignore } - } + } for (int i = 0; i < DEFAULT_MAX_QUEUE_SIZE; i++) { fillers[i] = new BlockingWorkItem();