{"record":{"id":"0de2a7f5d03920f2","repo":"redis/jedis","slug":"healthcheckstrategysupplier-must-not-be-null","errorCode":null,"errorMessage":"healthCheckStrategySupplier must not be null","messagePattern":"healthCheckStrategySupplier must not be null","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"src/main/java/redis/clients/jedis/MultiDbConfig.java","lineNumber":1127,"sourceCode":"        return this;\n      }\n\n      /**\n       * Sets a custom health check strategy supplier for this database.\n       * <p>\n       * The strategy supplier creates health check instances that monitor this database's\n       * availability. Different databases can use different health check strategies based on their\n       * specific requirements.\n       * </p>\n       * @param healthCheckStrategySupplier the health check strategy supplier\n       * @return this builder instance for method chaining\n       * @throws IllegalArgumentException if healthCheckStrategySupplier is null\n       * @see StrategySupplier\n       * @see redis.clients.jedis.mcf.HealthCheckStrategy\n       */\n      public Builder healthCheckStrategySupplier(StrategySupplier healthCheckStrategySupplier) {\n        if (healthCheckStrategySupplier == null) {\n          throw new IllegalArgumentException(\"healthCheckStrategySupplier must not be null\");\n        }\n        this.healthCheckStrategySupplier = healthCheckStrategySupplier;\n        return this;\n      }\n\n      /**\n       * Sets a specific health check strategy instance for this database.\n       * <p>\n       * This is a convenience method that wraps the provided strategy in a supplier that always\n       * returns the same instance. Use this when you have a pre-configured strategy instance.\n       * </p>\n       * <p>\n       * <strong>Note:</strong> The same strategy instance will be reused, so ensure it's\n       * thread-safe if multiple databases might use it.\n       * </p>\n       * @param healthCheckStrategy the health check strategy instance\n       * @return this builder instance for method chaining\n       * @throws IllegalArgumentException if healthCheckStrategy is null","sourceCodeStart":1109,"sourceCodeEnd":1145,"githubUrl":"https://github.com/redis/jedis/blob/6dac31d4c224fb3257c216f3985340c6f500cdcb/src/main/java/redis/clients/jedis/MultiDbConfig.java#L1109-L1145","documentation":"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.","triggerScenarios":"Calling MultiDbConfig.Builder.healthCheckStrategySupplier(null), typically by passing a supplier variable or factory method reference that resolved to null.","commonSituations":"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.","solutions":["Ensure the StrategySupplier you pass is non-null before calling the builder method.","If no custom strategy is needed, omit healthCheckStrategySupplier entirely and use the default strategy.","If you have an already-built HealthCheckStrategy, call healthCheckStrategy(strategy) instead of healthCheckStrategySupplier(null).","Fix whatever produces the null supplier (missing config file entry, DI misconfiguration) before building MultiDbConfig."],"exampleFix":"// before\nHealthCheckStrategy.Supplier supplier = loadSupplierFromConfig(); // may be null\nbuilder.healthCheckStrategySupplier(supplier); // throws\n\n// after\nHealthCheckStrategy.Supplier supplier = loadSupplierFromConfig();\nif (supplier != null) {\n  builder.healthCheckStrategySupplier(supplier);\n} else {\n  builder.healthCheckStrategy(DefaultHealthCheckStrategy.create(hostAndPort, jedisClientConfig));\n}","handlingStrategy":"validation","validationCode":"if (supplier == null) {\n  throw new IllegalStateException(\"healthCheckStrategySupplier not configured; provide a StrategySupplier or use the default\");\n}\nbuilder.healthCheckStrategySupplier(supplier);","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Centralize MultiDbConfig building in one factory method that applies defaults.","Null-check config values loaded from files/env before passing them to builders.","Prefer the healthCheckStrategy(HealthCheckStrategy) overload when you already hold an instance."],"tags":["configuration","null-check","multi-db","health-check"],"backgroundTag":"null-argument","analyzedSha":"6dac31d4c224fb3257c216f3985340c6f500cdcb","analyzedAt":"2026-09-08T04:55:01.204Z","contentChangedAt":"2026-09-08T04:55:01.204Z","schemaVersion":2},"datasetVersion":"2026-09-16T04:17:20.429Z"}