eclipse-vertx/vert.x · error · java.lang.IllegalArgumentException

cacheNegativeTimeToLive must be >= 0

Error message

cacheNegativeTimeToLive must be >= 0

What it means

Configuration validation in setCacheNegativeTimeToLive: the negative-cache TTL applied after failed hostname lookups must not be negative. A negative value would make no sense for the retry-suppression window, so the setter throws before assigning the field.

Source

Thrown at vertx-core/src/main/java/io/vertx/core/dns/AddressResolverOptions.java:376

  /**
   * @return the cache negative TTL in seconds
   */
  public int getCacheNegativeTimeToLive() {
    return cacheNegativeTimeToLive;
  }

  /**
   * Set the negative cache TTL value in seconds. After a failed hostname resolution, DNS queries won't be retried
   * for a period of time equals to the negative TTL. This allows to reduce the response time of negative replies
   * and reduce the amount of messages to DNS servers.
   *
   * @param cacheNegativeTimeToLive the cache negative TTL in seconds
   * @return a reference to this, so the API can be used fluently
   */
  public AddressResolverOptions setCacheNegativeTimeToLive(int cacheNegativeTimeToLive) {
    if (cacheNegativeTimeToLive < 0) {
      throw new IllegalArgumentException("cacheNegativeTimeToLive must be >= 0");
    }
    this.cacheNegativeTimeToLive = cacheNegativeTimeToLive;
    return this;
  }

  /**
   * @return the query timeout in milliseconds
   */
  public long getQueryTimeout() {
    return queryTimeout;
  }

  /**
   * Set the query timeout in milliseconds, i.e the amount of time after a query is considered to be failed.
   *
   * @param queryTimeout the query timeout in milliseconds
   * @return a reference to this, so the API can be used fluently
   */

View on GitHub (pinned to fb308bd8c3)

Solutions

  1. Pass a value >= 0 (0 disables negative caching, failed lookups are retried immediately)
  2. Validate deserialized JSON configuration before calling the setter
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at vertx-core/src/main/java/io/vertx/core/dns/AddressResolverOptions.java:376 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of eclipse-vertx/vert.x@fb308bd8c3 (2026-09-06). Data as JSON: /api/errors/a53dfb09b877c2f6. Report an issue: GitHub.