in src/main/java/com/aliyun/credentials/provider/EcsRamRoleCredentialProvider.java [90:118]
private void checkCredentialsUpdateAsynchronously() {
if (isAsyncCredentialUpdateEnabled()) {
executor = Executors.newScheduledThreadPool(1, new ThreadFactory() {
public Thread newThread(Runnable r) {
Thread t = Executors.defaultThreadFactory().newThread(r);
t.setName("imds-credentials-check-and-refresh");
t.setDaemon(true);
return t;
}
});
executor.scheduleWithFixedDelay(new Runnable() {
@Override
public void run() {
try {
if (shouldRefresh) {
logger.info("Begin checking or refreshing credentials asynchronously");
getCredentials();
}
} catch (Exception re) {
handleAsyncRefreshError(re);
}
}
private void handleAsyncRefreshError(Exception e) {
logger.warning("Failed when checking or refreshing credentials asynchronously, error: {}.", e.getMessage());
}
}, 0, ASYNC_REFRESH_INTERVAL_TIME_MINUTES, TimeUnit.MINUTES);
}
}