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

Conversation

alextwoods
Copy link
Contributor

@alextwoods alextwoods commented Jun 4, 2025

Fixes a warning logged from the CachedSupplier used by the ProfileFileRefresher that expiration (stale time) is in the past.

Motivation and Context

ProfileFileSupplier.defaultSupplier() and ProfileFileSupplier.reloadWhenModified() always logs a warning message indicating that the expiration/stale time is in the past. This happens every time the value is accessed from the cache, since we compare clock.instant() calculated at 2 separate instances:

Modifications

This change adds a stale time to now in the ProfileFileRefresher preventing the warning from being logged - and preventing the CachedSupplier from adding 1 second to the stale time when it detects this case.

Does this change any refresh behavior? Does this change when changes in the profile files are reloaded?
No - there should not be behavior changes.
In the current code, the ProfileFileRefresher sets a stale time of now, which always triggers the ProfileFileRefresher to detect a past expiration and adds 1 second to the stale time. This happens even when the values of clock.instant() are identical because the values are checked using isBefore which checks strictly less than and not equal.

This change adds the same 1 second delay to the stale time, but does so explicitly in the ProfileFileRefresher.

Testing

Modified existing test cases. Note that the test cases were incorrectly assuming that the CachedSupplier would use the jitter path - however, jitter is only applied in prefetch cases and when the staleValueBehavior is set to ALLOW - but in the ProfileFileRefresher, prefetch is never done (because prefetch time defaults to Instant.MAX) and staleValueBehavior is always STRICT.

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)

Checklist

  • I have read the CONTRIBUTING document
  • Local run of mvn install succeeds
  • My code follows the code style of this project
  • I have added tests to cover my changes
  • All new and existing tests passed
  • I have added a changelog entry. Adding a new entry must be accomplished by running the scripts/new-change script and following the instructions. Commit the new file created by the script in .changes/next-release with your changes.

License

  • I confirm that this pull request can be released under the Apache 2 license

@alextwoods alextwoods requested a review from a team as a code owner June 4, 2025 15:58
Copy link

sonarqubecloud bot commented Jun 5, 2025

@alextwoods alextwoods added this pull request to the merge queue Jun 5, 2025
Merged via the queue into master with commit 75604a3 Jun 5, 2025
34 of 35 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants