From e5f1d1149ad6cd660313a2bdbc176d819a7a0e5e Mon Sep 17 00:00:00 2001 From: Jaikiran Pai Date: Fri, 3 Jul 2020 08:54:36 +0530 Subject: [PATCH] Fix race condition in scheduler and quartz's ConcurrentExecutionTest --- .../java/io/quarkus/quartz/test/ConcurrentExecutionTest.java | 4 ++++ .../io/quarkus/scheduler/test/ConcurrentExecutionTest.java | 4 ++++ 2 files changed, 8 insertions(+) diff --git a/extensions/quartz/deployment/src/test/java/io/quarkus/quartz/test/ConcurrentExecutionTest.java b/extensions/quartz/deployment/src/test/java/io/quarkus/quartz/test/ConcurrentExecutionTest.java index bb5d96f4bb384..4176e6a0dadff 100644 --- a/extensions/quartz/deployment/src/test/java/io/quarkus/quartz/test/ConcurrentExecutionTest.java +++ b/extensions/quartz/deployment/src/test/java/io/quarkus/quartz/test/ConcurrentExecutionTest.java @@ -44,6 +44,10 @@ void concurrent() { @Scheduled(every = "1s", concurrentExecution = SKIP) void nonconcurrent() throws InterruptedException { + if (LATCH.getCount() == 0) { + // we are already done with our test, don't increment the counter anymore + return; + } COUNTER.incrementAndGet(); if (!LATCH.await(5, TimeUnit.SECONDS)) { throw new IllegalStateException(""); diff --git a/extensions/scheduler/deployment/src/test/java/io/quarkus/scheduler/test/ConcurrentExecutionTest.java b/extensions/scheduler/deployment/src/test/java/io/quarkus/scheduler/test/ConcurrentExecutionTest.java index d8d533333ff05..5dc9536544fb1 100644 --- a/extensions/scheduler/deployment/src/test/java/io/quarkus/scheduler/test/ConcurrentExecutionTest.java +++ b/extensions/scheduler/deployment/src/test/java/io/quarkus/scheduler/test/ConcurrentExecutionTest.java @@ -44,6 +44,10 @@ void concurrent() { @Scheduled(every = "1s", concurrentExecution = SKIP) void nonconcurrent() throws InterruptedException { + if (LATCH.getCount() == 0) { + // we are already done with our test, don't increment the counter anymore + return; + } COUNTER.incrementAndGet(); if (!LATCH.await(5, TimeUnit.SECONDS)) { throw new IllegalStateException("");