Skip to content

Commit

Permalink
Merge pull request #138 from camunda-cloud/stuck-tests
Browse files Browse the repository at this point in the history
Tests no longer randomly get stuck when waiting for idle state
  • Loading branch information
pihme authored Jan 12, 2022
2 parents 1954fc7 + 3069d9c commit c61ad17
Showing 1 changed file with 13 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -52,29 +52,27 @@ public void addCallback(final Runnable callback) {
}

private void checkIdleState() {
if (isInIdleState()) {
scheduleNotification();
} else {
cancelNotification();
synchronized (idleStateNotifier) {
if (isInIdleState()) {
scheduleNotification();
} else {
cancelNotification();
}
}
}

private void scheduleNotification() {
synchronized (idleStateNotifier) {
idleStateNotifier = createIdleStateNotifier();
try {
TIMER.schedule(idleStateNotifier, GRACE_PERIOD);
} catch (IllegalStateException e) {
// thrown - among others - if task was cancelled before it could be scheduled
// do nothing in this case
}
idleStateNotifier = createIdleStateNotifier();
try {
TIMER.schedule(idleStateNotifier, GRACE_PERIOD);
} catch (IllegalStateException e) {
// thrown - among others - if task was cancelled before it could be scheduled
// do nothing in this case
}
}

private void cancelNotification() {
synchronized (idleStateNotifier) {
idleStateNotifier.cancel();
}
idleStateNotifier.cancel();
}

private boolean isInIdleState() {
Expand Down

0 comments on commit c61ad17

Please sign in to comment.