eclipse-vertx/vert.x · info · IllegalArgumentException

maxExecuteTime must be > 0

Error message

maxExecuteTime must be > 0

What it means

SC_BAD_GATEWAY is an HttpResponseExpectation constant asserting an HTTP response status of 502. The companion int constant SC_BAD_GATEWAY = 502 also exists in HttpUtils for internal use. The expectation fails when the validated response status is not 502, surfacing the '502 Bad Gateway' message.

Source

Thrown at vertx-core/src/main/java/io/vertx/core/DeploymentOptions.java:242

   * @return The value of max worker execute time, the default value of {@link DeploymentOptions#setMaxWorkerExecuteTimeUnit} {@code maxWorkerExecuteTimeUnit} is {@link TimeUnit#NANOSECONDS}
   */
  public long getMaxWorkerExecuteTime() {
    return maxWorkerExecuteTime;
  }

  /**
   * Sets the value of max worker execute time, in {@link DeploymentOptions#setMaxWorkerExecuteTimeUnit maxWorkerExecuteTimeUnit}.
   * <p>
   * The default value of {@link DeploymentOptions#setMaxWorkerExecuteTimeUnit maxWorkerExecuteTimeUnit} is {@link TimeUnit#NANOSECONDS}
   * <p>
   * When the verticle does not use a {@link #getWorkerPoolName() named worker pool}, this option has no effect.
   *
   * @param maxWorkerExecuteTime the value of max worker execute time, in in {@link DeploymentOptions#setMaxWorkerExecuteTimeUnit maxWorkerExecuteTimeUnit}.
   * @return a reference to this, so the API can be used fluently
   */
  public DeploymentOptions setMaxWorkerExecuteTime(long maxWorkerExecuteTime) {
    if (maxWorkerExecuteTime < 1) {
      throw new IllegalArgumentException("maxExecuteTime must be > 0");
    }
    this.maxWorkerExecuteTime = maxWorkerExecuteTime;
    return this;
  }

  /**
   * When the verticle does not use a {@link #getWorkerPoolName() named worker pool}, this option has no effect.
   *
   * @return the time unit of {@code maxWorkerExecuteTime}
   */
  public TimeUnit getMaxWorkerExecuteTimeUnit() {
    return maxWorkerExecuteTimeUnit;
  }

  /**
   * Set the time unit of {@code maxWorkerExecuteTime}
   * <p>
   * When the verticle does not use a {@link #getWorkerPoolName() named worker pool}, this option has no effect.

View on GitHub (pinned to fb308bd8c3)

Solutions

  1. If 502 was not intended, fix the upstream/gateway availability or routing so the real expected status is returned.
  2. Update the expectation to the status the server actually returns, or accept a range via HttpResponseExpectation.status(...)/custom predicate.
  3. When deliberately testing gateway failures, keep SC_BAD_GATEWAY but ensure the reverse proxy is configured to produce 502 for the scenario.

Example fix

// before
request.expect(HttpResponseExpectation.SC_BAD_GATEWAY).send();
// after
request.expect(HttpResponseExpectation.status(200)).send();
Defensive patterns

Strategy: retry

Validate before calling

// treat 502 as transient upstream failure before validating
if (response.statusCode() == 502 && !retryAllowed) throw new IllegalStateException("Upstream gateway unavailable");

Prevention

When it happens

Trigger: Passing HttpResponseExpectation.SC_BAD_GATEWAY to a client expectation (request.expect(...)) against a response whose status is not exactly 502; internal Vert.x code comparing response codes against HttpUtils.SC_BAD_GATEWAY.

Common situations: A gateway/proxy behind the Vert.x client returned 502 because the upstream is down, while the test/code expected a different status; integration tests asserting proxy failure semantics.

Related errors


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