redis/jedis · error · JedisConnectionException
Interrupted while waiting for health check result
Error message
Interrupted while waiting for health check result
What it means
waitForHealthStatus catches InterruptedException while awaiting the health status latch, re-interrupts the current thread to preserve the interrupt flag, and rethrows as JedisConnectionException. This happens when the waiting thread is interrupted (task cancellation or shutdown) rather than when the health check times out.
Solutions
- Avoid closing or shutting down the client while initialization is still in progress; await build()/initialization completion first.
- Catch JedisConnectionException at the initialization call site and treat it as shutdown-in-progress rather than retrying.
- Ensure worker threads executing initialization are not cancelled prematurely by executor shutdownNow().
- If interrupts are intentional, rely on the exception to abort and clean up; the tracker already unregisters its listener in finally.
Example fix
// before
ExecutorService es = Executors.newSingleThreadExecutor();
es.shutdownNow(); // interrupts client init thread mid health-wait
// after
ClientInitTask task = new ClientInitTask();
Future<?> f = es.submit(task);
f.get(60, TimeUnit.SECONDS); // let init finish
es.shutdown();
// catch site
try {
client = buildClient();
} catch (JedisConnectionException e) {
if (Thread.currentThread().isInterrupted()) {
// shutdown in progress; do not retry
}
} Defensive patterns
Strategy: try-catch
Validate before calling
if (Thread.currentThread().isInterrupted()) { /* skip init */ } Try / catch
try {
tracker.waitForHealthStatus(endpoint);
} catch (JedisConnectionException e) {
if (Thread.currentThread().isInterrupted()) {
// shutdown in progress; abort without retry
return;
}
throw e;
} Prevention
- Do not interrupt threads while client initialization is running.
- Await build()/init completion before calling close().
- Use shutdown() (not shutdownNow()) for executors running client init.
When it happens
Trigger: The thread blocked in latch.await() inside waitForHealthStatus (via waitForInitializationPolicy) receives Thread.interrupt() — e.g. client close() during initialization, executor shutdown, application shutdown hooks, or Future cancellation of the initialization task.
Common situations: Closing a MultiDb client from another thread while it is still initializing; shutting down an application server mid-initialization; cancelling an initialization Future; test frameworks interrupting leaked threads between tests.
Related errors
- healthCheckStrategySupplier must not be null
- healthCheckStrategy must not be null
- No BDB found matching host
- Error while checking availability
- Database can not be removed due to no healthy database…
AI-assisted analysis of redis/jedis@6dac31d4c2 (2026-09-08).
Data as JSON: /api/errors/10d7445a824ee4f0.
Report an issue: GitHub.
Appendix: source
Thrown at src/main/java/redis/clients/jedis/mcf/StatusTracker.java:74
try {
// Double-check status after registering listener (race condition protection)
currentStatus = healthStatusManager.getHealthStatus(endpoint);
if (currentStatus != HealthStatus.UNKNOWN) {
return currentStatus;
}
// Wait for the health status change event
// just for safety to not block indefinitely
boolean completed = latch.await(healthStatusManager.getMaxWaitFor(endpoint),
TimeUnit.MILLISECONDS);
if (!completed) {
throw new JedisValidationException("Timeout while waiting for health check result");
}
return resultStatus.get();
} catch (InterruptedException e) {
Thread.currentThread().interrupt();
throw new JedisConnectionException("Interrupted while waiting for health check result", e);
} finally {
// Clean up: unregister the temporary listener
healthStatusManager.unregisterListener(endpoint, tempListener);
}
}
}
View on GitHub (pinned to 6dac31d4c2)