redis/jedis · error · IllegalArgumentException

healthCheckStrategySupplier must not be null

Error message

healthCheckStrategySupplier must not be null

What it means

MultiDbConfig.Builder.healthCheckStrategySupplier() requires a non-null StrategySupplier that produces a HealthCheckStrategy per database. A null supplier would leave the multi-db client unable to construct health checks for a database at runtime, so the builder fails fast with IllegalArgumentException during configuration.

Solutions

  1. Ensure the StrategySupplier you pass is non-null before calling the builder method.
  2. If no custom strategy is needed, omit healthCheckStrategySupplier entirely and use the default strategy.
  3. If you have an already-built HealthCheckStrategy, call healthCheckStrategy(strategy) instead of healthCheckStrategySupplier(null).
  4. Fix whatever produces the null supplier (missing config file entry, DI misconfiguration) before building MultiDbConfig.

Example fix

// before
HealthCheckStrategy.Supplier supplier = loadSupplierFromConfig(); // may be null
builder.healthCheckStrategySupplier(supplier); // throws

// after
HealthCheckStrategy.Supplier supplier = loadSupplierFromConfig();
if (supplier != null) {
  builder.healthCheckStrategySupplier(supplier);
} else {
  builder.healthCheckStrategy(DefaultHealthCheckStrategy.create(hostAndPort, jedisClientConfig));
}
Defensive patterns

Strategy: validation

Validate before calling

if (supplier == null) {
  throw new IllegalStateException("healthCheckStrategySupplier not configured; provide a StrategySupplier or use the default");
}
builder.healthCheckStrategySupplier(supplier);

Prevention

When it happens

Trigger: Calling MultiDbConfig.Builder.healthCheckStrategySupplier(null), typically by passing a supplier variable or factory method reference that resolved to null.

Common situations: Conditional config code that only assigns the supplier under some flag (e.g. reading strategy config from properties/yaml that is absent), or a factory bean that returns null in a DI container.

Related errors


AI-assisted analysis of redis/jedis@6dac31d4c2 (2026-09-08). Data as JSON: /api/errors/0de2a7f5d03920f2. Report an issue: GitHub.

Appendix: source

Thrown at src/main/java/redis/clients/jedis/MultiDbConfig.java:1127

        return this;
      }

      /**
       * Sets a custom health check strategy supplier for this database.
       * <p>
       * The strategy supplier creates health check instances that monitor this database's
       * availability. Different databases can use different health check strategies based on their
       * specific requirements.
       * </p>
       * @param healthCheckStrategySupplier the health check strategy supplier
       * @return this builder instance for method chaining
       * @throws IllegalArgumentException if healthCheckStrategySupplier is null
       * @see StrategySupplier
       * @see redis.clients.jedis.mcf.HealthCheckStrategy
       */
      public Builder healthCheckStrategySupplier(StrategySupplier healthCheckStrategySupplier) {
        if (healthCheckStrategySupplier == null) {
          throw new IllegalArgumentException("healthCheckStrategySupplier must not be null");
        }
        this.healthCheckStrategySupplier = healthCheckStrategySupplier;
        return this;
      }

      /**
       * 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

View on GitHub (pinned to 6dac31d4c2)