{"record":{"id":"9f3d49467e1e903a","repo":"eclipse-vertx/vert.x","slug":"cachemintimetolive-must-be-0","errorCode":null,"errorMessage":"cacheMinTimeToLive must be >= 0","messagePattern":"cacheMinTimeToLive must be >= 0","errorType":"exception","errorClass":"java.lang.IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"vertx-core/src/main/java/io/vertx/core/dns/AddressResolverOptions.java","lineNumber":331,"sourceCode":"  }\n\n  /**\n   * @return the cache min TTL in seconds\n   */\n  public int getCacheMinTimeToLive() {\n    return cacheMinTimeToLive;\n  }\n\n  /**\n   * Set the cache minimum TTL value in seconds. After resolution successful IP addresses are cached with their DNS response TTL,\n   * use this to set a minimum value to all responses TTL.\n   *\n   * @param cacheMinTimeToLive the cache min TTL in seconds\n   * @return a reference to this, so the API can be used fluently\n   */\n  public AddressResolverOptions setCacheMinTimeToLive(int cacheMinTimeToLive) {\n    if (cacheMinTimeToLive < 0) {\n      throw new IllegalArgumentException(\"cacheMinTimeToLive must be >= 0\");\n    }\n    this.cacheMinTimeToLive = cacheMinTimeToLive;\n    return this;\n  }\n\n  /**\n   * @return the cache max TTL in seconds\n   */\n  public int getCacheMaxTimeToLive() {\n    return cacheMaxTimeToLive;\n  }\n\n  /**\n   * Set the cache maximum TTL value in seconds. After successful resolution IP addresses are cached with their DNS response TTL,\n   * use this to set a maximum value to all responses TTL.\n   *\n   * @param cacheMaxTimeToLive the cache max TTL in seconds\n   * @return a reference to this, so the API can be used fluently","sourceCodeStart":313,"sourceCodeEnd":349,"githubUrl":"https://github.com/eclipse-vertx/vert.x/blob/fb308bd8c3f12c79f4ae89bef67fadf6c80d036e/vertx-core/src/main/java/io/vertx/core/dns/AddressResolverOptions.java#L313-L349","documentation":"AddressResolverOptions.setCacheMinTimeToLive throws IllegalArgumentException with \"cacheMinTimeToLive must be >= 0\" when given a negative TTL. This setting (in seconds) clamps cached DNS entries to a minimum lifetime regardless of the record's TTL; negative values are invalid clamp bounds. Validation is eager, most often reached via AddressResolverOptions.fromJson while bootstrapping the resolver.","triggerScenarios":"new AddressResolverOptions().setCacheMinTimeToLive(-1); fromJson with \"cacheMinTimeToLive\" < 0; tests like testOptions exercising defaults and bounds.","commonSituations":"Passing -1 to mean 'no minimum' instead of 0; config files where min > max was 'fixed' by negating the min; unit or sign errors when generating options programmatically from user input.","solutions":["Pass 0 (no minimum clamp) or a positive number of seconds.","Ensure the paired setCacheMaxTimeToLive >= setCacheMinTimeToLive to keep the cache range sensible.","Validate/clamp the JSON field before fromJson: use Math.max(0, value) or reject the config."],"exampleFix":"// before\nresolverOpts.setCacheMinTimeToLive(-1); // intent: no minimum\n// after\nresolverOpts.setCacheMinTimeToLive(0); // 0 = no minimum TTL clamp","handlingStrategy":"validation","validationCode":"if (minTtl < 0) throw new IllegalArgumentException(\"cacheMinTimeToLive must be >= 0\");\nresolverOptions.setCacheMinTimeToLive(minTtl);","typeGuard":null,"tryCatchPattern":"try {\n  resolverOptions.setCacheMinTimeToLive(v);\n} catch (IllegalArgumentException e) {\n  log.warn(\"Invalid cacheMinTimeToLive {}, defaulting to 0\", v);\n  resolverOptions.setCacheMinTimeToLive(0);\n}","preventionTips":["Use 0, never a negative number, to express 'no minimum TTL'","Keep min <= max by validating both TTLs together","Validate TTL fields from user input at the config-loading layer"],"tags":["vertx","dns","cache","configuration"],"backgroundTag":"invalid-config-value","analyzedSha":"fb308bd8c3f12c79f4ae89bef67fadf6c80d036e","analyzedAt":"2026-09-06T11:37:12.241Z","contentChangedAt":"2026-09-06T11:37:12.241Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}