This is an automated email from the ASF dual-hosted git repository. clebertsuconic pushed a commit to branch 2.19.x in repository https://gitbox.apache.org/repos/asf/activemq-artemis.git
commit 54150aaeb5bd527a5eff8ce2c0cfe29682149251 Author: Clebert Suconic <[email protected]> AuthorDate: Mon Dec 13 12:04:25 2021 -0500 ARTEMIS-3604 Test Improvement (cherry picked from commit b5eb7d234212d2e7ad0276f5a6b84857a6f1d842) --- .../artemis/utils/actors/ThresholdActorTest.java | 22 +++++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) diff --git a/artemis-commons/src/test/java/org/apache/activemq/artemis/utils/actors/ThresholdActorTest.java b/artemis-commons/src/test/java/org/apache/activemq/artemis/utils/actors/ThresholdActorTest.java index 01e5471..94642a3 100644 --- a/artemis-commons/src/test/java/org/apache/activemq/artemis/utils/actors/ThresholdActorTest.java +++ b/artemis-commons/src/test/java/org/apache/activemq/artemis/utils/actors/ThresholdActorTest.java @@ -121,7 +121,7 @@ public class ThresholdActorTest { public void block() { try { - if (!semaphore.tryAcquire(10, TimeUnit.SECONDS)) { + if (!semaphore.tryAcquire()) { errors.incrementAndGet(); System.err.println("acquire failed"); } @@ -136,6 +136,20 @@ public class ThresholdActorTest { @Test public void testFlow() throws Exception { + testFlow(true); + } + + /** + * This test will actually not respect the semaphore and keep going. + * The blockers and unblocks should still perform ok. + * @throws Exception + */ + @Test + public void testFlow2() throws Exception { + testFlow(false); + } + + public void testFlow(boolean respectSemaphore) throws Exception { final ExecutorService executorService = Executors.newFixedThreadPool(2); try { @@ -148,8 +162,10 @@ public class ThresholdActorTest { executorService.execute(() -> { for (int i = 0; i <= LAST_ELEMENT; i++) { try { - semaphore.acquire(); - semaphore.release(); + if (respectSemaphore) { + semaphore.acquire(); + semaphore.release(); + } actor.act(new Element(i, i % 2 == 0 ? 20 : 1)); } catch (Exception e) { e.printStackTrace();
