public AlibabaCloudCredentials getCredentials() throws ClientException {if (credentials == null || credentials.isExpired()) {ecsMetadataServiceFetchCount += 1;int maxRetryTimes = MAX_ECS_METADATA_FETCH_RETRY_TIMES;credentials = fetcher.fetch(maxRetryTimes);} else if (credentials.willSoonExpire() && credentials.shouldRefresh()) {try {ecsMetadataServiceFetchCount += 1;credentials = fetcher.fetch();} catch (ClientException e) {credentials.setLastFailedRefreshTime();}}return credentials;}
public virtual AlibabaCloudCredentials GetCredentials(){try{if (credentials == null){credentials = fetcher.Fetch(maxRetryTimes);}if (credentials.IsExpired()){throw new ClientException("SDK.SessionTokenExpired", "Current session token has expired.");}if (!credentials.WillSoonExpire() || !credentials.ShouldRefresh()){return credentials;}credentials = fetcher.Fetch();return credentials;}catch (ClientException ex){if (ex.ErrorCode.Equals("SDK.SessionTokenExpired") &&ex.ErrorMessage.Equals("Current session token has expired.")){CommonLog.LogException(ex, ex.ErrorCode, ex.ErrorMessage);throw new ClientException(ex.ErrorCode, ex.ErrorMessage);}credentials.SetLastFailedRefreshTime();}return credentials;}