Skip to content

Conversation

@jayblanc
Copy link
Contributor

This pull request refactors the HealthCheckService to improve thread safety, caching, and concurrency, as well as to simplify the health check execution logic. The main changes include introducing a cache for health check results, switching to a cached thread pool, and removing unnecessary stream usage.

Thread safety and caching improvements:

  • Added a cache (healthCache) for health check results, a timestamp (cacheTimestamp), and synchronization logic to prevent concurrent refreshes. This ensures results are not recomputed too frequently and improves performance under load. [1] [2]
  • Introduced a cacheLock object and busy flag to coordinate cache refreshes and avoid race conditions. [1] [2]

Concurrency and execution changes:

  • Changed the executor from a single-threaded executor to a cached thread pool to better handle concurrent health check provider executions.
  • Removed the use of Future and timeouts when executing health check providers; now calls provider.execute() directly and handles exceptions by marking the provider as timed out.

Code simplification and cleanup:

  • Removed unnecessary use of streams and collectors when filtering providers, simplifying the code with a direct toList() call. [1] [2]
  • Improved logging and early returns when the health check service is disabled.

@jayblanc jayblanc merged commit 0c44c9b into master Dec 31, 2025
6 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.

2 participants