Skip to content

Fix expiration in past warning from ProfileFileRefresher. #6157

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 7 commits into from
Jun 5, 2025
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions .changes/next-release/bugfix-AWSSDKforJavav2-8565660.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"type": "bugfix",
"category": "AWS SDK for Java v2",
"contributor": "",
"description": "Fix expiration in past warning from ProfileFileRefresher."
}
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ public final class ProfileFileRefresher {
private static final ProfileFileRefreshRecord EMPTY_REFRESH_RECORD = ProfileFileRefreshRecord.builder()
.refreshTime(Instant.MIN)
.build();
private static final long STALE_TIME_MS = 1000;
private final CachedSupplier<ProfileFileRefreshRecord> profileFileCache;
private volatile ProfileFileRefreshRecord currentRefreshRecord;
private final Supplier<ProfileFile> profileFile;
Expand Down Expand Up @@ -96,7 +97,7 @@ private RefreshResult<ProfileFileRefreshRecord> reloadAsRefreshResultIfStale() {
refreshRecord = currentRefreshRecord;
}

return wrapIntoRefreshResult(refreshRecord, now);
return wrapIntoRefreshResult(refreshRecord, now.plusMillis(STALE_TIME_MS));
}

private <T> RefreshResult<T> wrapIntoRefreshResult(T value, Instant staleTime) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ void refreshIfStale_profileModifiedNoPathSpecified_doesNotReloadProfileFile() {
}

@Test
void refreshIfStale_profileModifiedWithinJitterPeriod_doesNotReloadProfileFile() {
void refreshIfStale_profileModifiedWithinStalePeriod_doesNotReloadProfileFile() {
Path credentialsFilePath = generateTestCredentialsFile("defaultAccessKey", "defaultSecretAccessKey");

AdjustableClock clock = new AdjustableClock();
Expand All @@ -99,7 +99,7 @@ void refreshIfStale_profileModifiedWithinJitterPeriod_doesNotReloadProfileFile()
}

@Test
void refreshIfStale_profileModifiedOutsideJitterPeriod_reloadsProfileFile() {
void refreshIfStale_profileModifiedOutsideStalePeriod_reloadsProfileFile() {
Path credentialsFilePath = generateTestCredentialsFile("defaultAccessKey", "defaultSecretAccessKey");

AdjustableClock clock = new AdjustableClock();
Expand Down
Loading