Skip to content

Commit

Permalink
Merge pull request #10444 from jaikiran/scheduler-test-race
Browse files Browse the repository at this point in the history
Fix race condition in scheduler and quartz's ConcurrentExecutionTest
  • Loading branch information
geoand authored Jul 3, 2020
2 parents 2f20cf5 + e5f1d11 commit 71e2452
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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("");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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("");
Expand Down

0 comments on commit 71e2452

Please sign in to comment.