in src/main/java/com/aliyun/oss/common/auth/InstanceProfileCredentialsProvider.java [54:87]
public InstanceProfileCredentials getCredentials() {
if (credentials == null || credentials.isExpired()) {
try {
lock.lock();
if (credentials == null || credentials.isExpired()) {
try {
credentials = (InstanceProfileCredentials) fetcher.fetch(maxRetryTimes);
} catch (ClientException e) {
LogUtils.logException("EcsInstanceCredentialsFetcher.fetch Exception:", e);
return null;
}
}
} finally {
lock.unlock();
}
} else if (credentials.willSoonExpire() && credentials.shouldRefresh()) {
try {
lock.lock();
if (credentials.willSoonExpire() && credentials.shouldRefresh()) {
try {
credentials = (InstanceProfileCredentials) fetcher.fetch();
} catch (ClientException e) {
// Use the current expiring session token and wait for next round
credentials.setLastFailedRefreshTime();
LogUtils.logException("EcsInstanceCredentialsFetcher.fetch Exception:", e);
}
}
} finally {
lock.unlock();
}
}
return credentials;
}