Skip to content

Commit

Permalink
Handle exceptions while updating credentials better (#199)
Browse files Browse the repository at this point in the history
Runtime exceptions while updating credentials will no longer kill the
credential update thread.

Interrupted exceptions can be thrown while a thread pool/executor is
being shutdown.  This now handles that case without a message.

Mitigates/Fixes #49
  • Loading branch information
pfifer authored and sahilpalvia committed Apr 10, 2018
1 parent 534968d commit 4bcbd60
Showing 1 changed file with 15 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -318,9 +318,22 @@ public void run() {
while (!shutdown.get()) {
try {
updateCredentials();
Thread.sleep(config.getCredentialsRefreshDelay());
} catch (InterruptedException e) {
log.warn("Exception during updateCredentials", e);
//
// If interrupted it's likely the KPL is shutting down. So clear the
// interrupted status and allow the loop to continue.
//
} catch (RuntimeException re) {
log.error(
"Caught runtime exception while updating credentials. Will retry after refresh delay",
re);
}
try {
Thread.sleep(config.getCredentialsRefreshDelay());
} catch (InterruptedException ie) {
//
// Same as above it's likely safe to ignore this as the KPL is probably shutting down.
//
}
}
}
Expand Down

0 comments on commit 4bcbd60

Please sign in to comment.