{"record":{"id":"d0d974e9c9f445ca","repo":"eclipse-vertx/vert.x","slug":"cachemaxtimetolive-must-be-0","errorCode":null,"errorMessage":"cacheMaxTimeToLive must be >= 0","messagePattern":"cacheMaxTimeToLive 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":353,"sourceCode":"  }\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\n   */\n  public AddressResolverOptions setCacheMaxTimeToLive(int cacheMaxTimeToLive) {\n    if (cacheMaxTimeToLive < 0) {\n      throw new IllegalArgumentException(\"cacheMaxTimeToLive must be >= 0\");\n    }\n    this.cacheMaxTimeToLive = cacheMaxTimeToLive;\n    return this;\n  }\n\n  /**\n   * @return the cache negative TTL in seconds\n   */\n  public int getCacheNegativeTimeToLive() {\n    return cacheNegativeTimeToLive;\n  }\n\n  /**\n   * Set the negative cache TTL value in seconds. After a failed hostname resolution, DNS queries won't be retried\n   * for a period of time equals to the negative TTL. This allows to reduce the response time of negative replies\n   * and reduce the amount of messages to DNS servers.\n   *\n   * @param cacheNegativeTimeToLive the cache negative TTL in seconds","sourceCodeStart":335,"sourceCodeEnd":371,"githubUrl":"https://github.com/eclipse-vertx/vert.x/blob/fb308bd8c3f12c79f4ae89bef67fadf6c80d036e/vertx-core/src/main/java/io/vertx/core/dns/AddressResolverOptions.java#L335-L371","documentation":"Configuration validation in the fluent setter: setCacheMaxTimeToLive rejects a negative cacheMaxTimeToLive argument. The DNS resolver caches resolved addresses with the DNS response TTL capped at this value, and a negative cap is meaningless, so the setter throws immediately before the options object is mutated.","triggerScenarios":"Thrown at vertx-core/src/main/java/io/vertx/core/dns/AddressResolverOptions.java:353 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Pass a value >= 0 (0 disables the max TTL cap and uses the DNS response TTL as-is)","When loading options from JSON via fromJson, sanitize or remove negative cacheMaxTimeToLive entries before constructing AddressResolverOptions"],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"fb308bd8c3f12c79f4ae89bef67fadf6c80d036e","analyzedAt":"2026-09-06T11:37:12.241Z","contentChangedAt":"2026-09-06T11:37:12.241Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}