Skip to content

Commit

Permalink
Prevent crash when outgoingQueueIdlingResource is idle on message deq…
Browse files Browse the repository at this point in the history
…ueue success
  • Loading branch information
growse committed Aug 18, 2021
1 parent 0a65c3c commit a12842d
Showing 1 changed file with 9 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,6 @@ public MessageProcessor(
outgoingQueueIdlingResource.increment();
}
}

}

synchronized public void initialize() {
Expand Down Expand Up @@ -291,7 +290,15 @@ private void sendAvailableMessages() {
Thread.sleep(retryWait);
retryWait = Math.min(2 * retryWait, SEND_FAILURE_BACKOFF_MAX_WAIT);
} else {
outgoingQueueIdlingResource.decrement();
synchronized (outgoingQueueIdlingResource) {
try {
if (!outgoingQueueIdlingResource.isIdleNow()) {
outgoingQueueIdlingResource.decrement();
}
} catch (IllegalStateException e) {
Timber.w(e, "outgoingQueueIdlingResource is invalid");
}
}
}
} catch (InterruptedException e) {
Timber.i(e, "Outgoing message loop interrupted");
Expand Down

0 comments on commit a12842d

Please sign in to comment.