Skip to content

Commit

Permalink
Adding try/catch when unable to reschedule scheduler task.
Browse files Browse the repository at this point in the history
  • Loading branch information
conniey committed Jun 22, 2019
1 parent e100b23 commit ef030ee
Showing 1 changed file with 10 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,12 @@ Mono<Void> authorize() {
lastRefreshInterval.set(refreshIntervalMS);

// This converts it to milliseconds
this.timer.schedule(new RefreshAuthorizationToken(), refreshIntervalMS);
try {
this.timer.schedule(new RefreshAuthorizationToken(), refreshIntervalMS);
} catch (IllegalStateException e) {
logger.asWarning().log("Unable to reschedule timer task.", e);
hasScheduled.set(false);
}
}

return expiresOn;
Expand Down Expand Up @@ -123,8 +128,11 @@ public void run() {
logger.asInfo().log("Success. Rescheduling refresh authorization task.");
sink.next(AmqpResponseCode.ACCEPTED);

if (hasScheduled.getAndSet(true)) {
try {
timer.schedule(new RefreshAuthorizationToken(), lastRefreshInterval.get());
} catch (IllegalStateException e) {
logger.asWarning().log("Unable to reschedule timer task.", e);
hasScheduled.set(false);
}
});
}
Expand Down

0 comments on commit ef030ee

Please sign in to comment.