{"record":{"id":"e814515655a0c75a","repo":"redis/jedis","slug":"max-total-retries-duration-cannot-be-negative-for","errorCode":null,"errorMessage":"Max total retries duration cannot be negative for cluster mode","messagePattern":"Max total retries duration cannot be negative for cluster mode","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"src/main/java/redis/clients/jedis/builders/ClusterClientBuilder.java","lineNumber":149,"sourceCode":"    return new ClusterCommandExecutor((ClusterConnectionProvider) this.connectionProvider,\n        this.maxAttempts, effectiveMaxTotalRetriesDuration, this.commandFlags);\n  }\n\n  @Override\n  protected void validateSpecificConfiguration() {\n    validateCommonConfiguration();\n\n    if (nodes == null || nodes.isEmpty()) {\n      throw new IllegalArgumentException(\n          \"At least one cluster node must be specified for cluster mode\");\n    }\n\n    if (maxAttempts <= 0) {\n      throw new IllegalArgumentException(\"Max attempts must be positive for cluster mode\");\n    }\n\n    if (maxTotalRetriesDuration != null && maxTotalRetriesDuration.isNegative()) {\n      throw new IllegalArgumentException(\n          \"Max total retries duration cannot be negative for cluster mode\");\n    }\n\n    if (topologyRefreshPeriod != null && topologyRefreshPeriod.isNegative()) {\n      throw new IllegalArgumentException(\n          \"Topology refresh period cannot be negative for cluster mode\");\n    }\n  }\n\n}\n","sourceCodeStart":131,"sourceCodeEnd":160,"githubUrl":"https://github.com/redis/jedis/blob/6dac31d4c224fb3257c216f3985340c6f500cdcb/src/main/java/redis/clients/jedis/builders/ClusterClientBuilder.java#L131-L160","documentation":"maxTotalRetriesDuration bounds the total wall-clock time spent retrying a cluster command. validateSpecificConfiguration() throws this IllegalArgumentException when the supplied Duration is negative; a negative duration makes no temporal sense and would corrupt the retry deadline computation.","triggerScenarios":"Calling RedisClusterClient.builder().maxTotalRetriesDuration(Duration.ofSeconds(-1)) or any negative Duration, then build().","commonSituations":"A duration parsed from a config string with a leading minus sign; arithmetic on durations (e.g. subtracting) yielding a negative value; confusing Duration.ofMillis(-1) sentinel values.","solutions":["Pass a non-negative Duration, e.g. Duration.ofSeconds(2); use Duration.ZERO only if you truly want no retry window.","Validate or clamp durations from configuration: if (d.isNegative()) throw/clamp before building.","Use Duration.parse() on well-formed ISO-8601 strings (e.g. PT2S) and reject negative input at config-load time."],"exampleFix":"// before\nbuilder.maxTotalRetriesDuration(Duration.ofSeconds(-2)).build(); // throws\n// after\nbuilder.maxTotalRetriesDuration(Duration.ofSeconds(2)).build();","handlingStrategy":"validation","validationCode":"if (maxTotalRetriesDuration != null && maxTotalRetriesDuration.isNegative()) {\n  throw new IllegalArgumentException(\"maxTotalRetriesDuration must be non-negative\");\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Build durations with Duration.ofSeconds/ofMillis constants, never by arithmetic that can go negative.","Sanitize ISO-8601 duration strings from config before Duration.parse.","Document non-negative requirements where durations are entered by operators."],"tags":["jedis","cluster","builder","duration","configuration"],"backgroundTag":"invalid-config-value","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"}