redis/jedis · error · IllegalArgumentException
healthCheckStrategy must not be null
Error message
healthCheckStrategy must not be null
What it means
MultiDbConfig.Builder.healthCheckStrategy(HealthCheckStrategy) wraps the given strategy in a supplier, but rejects null up front with IllegalArgumentException. Building a HealthCheckStrategy with expensive/checked settings (interval, timeout, failuresBeforeFailover) and passing it null is a configuration bug, so the builder fails fast.
Solutions
- Pass a constructed HealthCheckStrategy instance, e.g. IntervalStrategy or DefaultHealthCheckStrategy.create(hostAndPort, clientConfig).
- Omit the call entirely to use the built-in default strategy.
- Null-check your strategy factory output before invoking the builder.
Example fix
// before
HealthCheckStrategy strategy = createStrategy(config); // null when config absent
builder.healthCheckStrategy(strategy); // throws
// after
HealthCheckStrategy strategy = createStrategy(config);
if (strategy == null) {
strategy = DefaultHealthCheckStrategy.create(host, jedisClientConfig);
}
builder.healthCheckStrategy(strategy); Defensive patterns
Strategy: validation
Validate before calling
if (strategy == null) {
strategy = DefaultHealthCheckStrategy.create(hostAndPort, jedisClientConfig);
}
builder.healthCheckStrategy(strategy); Prevention
- Provide a default HealthCheckStrategy in environment-specific config classes.
- Validate strategy-producing factories with unit tests that assert non-null output.
- Use Objects.requireNonNull early where strategies are constructed.
When it happens
Trigger: Calling MultiDbConfig.Builder.healthCheckStrategy(null), e.g. a strategy built by a helper that returned null or a field not yet initialized.
Common situations: Factories that build strategies conditionally per environment (no strategy defined for local dev), or refactoring where the strategy variable assignment was dropped.
Related errors
- healthCheckStrategySupplier must not be null
- No BDB found matching host
- protocol must not be null
- protocol must not be null
- At least one endpoint must be specified
AI-assisted analysis of redis/jedis@6dac31d4c2 (2026-09-08).
Data as JSON: /api/errors/a7191f8901632e54.
Report an issue: GitHub.
Appendix: source
Thrown at src/main/java/redis/clients/jedis/MultiDbConfig.java:1150
/**
* Sets a specific health check strategy instance for this database.
* <p>
* This is a convenience method that wraps the provided strategy in a supplier that always
* returns the same instance. Use this when you have a pre-configured strategy instance.
* </p>
* <p>
* <strong>Note:</strong> The same strategy instance will be reused, so ensure it's
* thread-safe if multiple databases might use it.
* </p>
* @param healthCheckStrategy the health check strategy instance
* @return this builder instance for method chaining
* @throws IllegalArgumentException if healthCheckStrategy is null
* @see #healthCheckStrategySupplier(StrategySupplier)
*/
public Builder healthCheckStrategy(HealthCheckStrategy healthCheckStrategy) {
if (healthCheckStrategy == null) {
throw new IllegalArgumentException("healthCheckStrategy must not be null");
}
this.healthCheckStrategySupplier = (hostAndPort, jedisClientConfig) -> healthCheckStrategy;
return this;
}
/**
* Enables or disables health checks for this database.
* <p>
* When health checks are disabled (false), the database will not be proactively monitored for
* availability. This means:
* </p>
* <ul>
* <li>No background health check threads will be created</li>
* <li>Failback to this database must be triggered manually</li>
* <li>The database is assumed to be healthy unless circuit breaker opens</li>
* </ul>
* <p>
* When health checks are enabled (true) and no strategy supplier was previously set, theView on GitHub (pinned to 6dac31d4c2)