{"record":{"id":"a7191f8901632e54","repo":"redis/jedis","slug":"healthcheckstrategy-must-not-be-null","errorCode":null,"errorMessage":"healthCheckStrategy must not be null","messagePattern":"healthCheckStrategy must not be null","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"src/main/java/redis/clients/jedis/MultiDbConfig.java","lineNumber":1150,"sourceCode":"\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\n       * @see #healthCheckStrategySupplier(StrategySupplier)\n       */\n      public Builder healthCheckStrategy(HealthCheckStrategy healthCheckStrategy) {\n        if (healthCheckStrategy == null) {\n          throw new IllegalArgumentException(\"healthCheckStrategy must not be null\");\n        }\n        this.healthCheckStrategySupplier = (hostAndPort, jedisClientConfig) -> healthCheckStrategy;\n        return this;\n      }\n\n      /**\n       * Enables or disables health checks for this database.\n       * <p>\n       * When health checks are disabled (false), the database will not be proactively monitored for\n       * availability. This means:\n       * </p>\n       * <ul>\n       * <li>No background health check threads will be created</li>\n       * <li>Failback to this database must be triggered manually</li>\n       * <li>The database is assumed to be healthy unless circuit breaker opens</li>\n       * </ul>\n       * <p>\n       * When health checks are enabled (true) and no strategy supplier was previously set, the","sourceCodeStart":1132,"sourceCodeEnd":1168,"githubUrl":"https://github.com/redis/jedis/blob/6dac31d4c224fb3257c216f3985340c6f500cdcb/src/main/java/redis/clients/jedis/MultiDbConfig.java#L1132-L1168","documentation":"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.","triggerScenarios":"Calling MultiDbConfig.Builder.healthCheckStrategy(null), e.g. a strategy built by a helper that returned null or a field not yet initialized.","commonSituations":"Factories that build strategies conditionally per environment (no strategy defined for local dev), or refactoring where the strategy variable assignment was dropped.","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."],"exampleFix":"// before\nHealthCheckStrategy strategy = createStrategy(config); // null when config absent\nbuilder.healthCheckStrategy(strategy); // throws\n\n// after\nHealthCheckStrategy strategy = createStrategy(config);\nif (strategy == null) {\n  strategy = DefaultHealthCheckStrategy.create(host, jedisClientConfig);\n}\nbuilder.healthCheckStrategy(strategy);","handlingStrategy":"validation","validationCode":"if (strategy == null) {\n  strategy = DefaultHealthCheckStrategy.create(hostAndPort, jedisClientConfig);\n}\nbuilder.healthCheckStrategy(strategy);","typeGuard":null,"tryCatchPattern":null,"preventionTips":["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."],"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"}