eclipse-vertx/vert.x · info · IllegalArgumentException

size must be > 0

Error message

size must be > 0

What it means

SC_NOT_IMPLEMENTED is a public HttpResponseExpectation constant in Vert.x core asserting that an HTTP response status equals 501. It is not thrown by the library; it is an expectation passed to HttpResponseExpectation-based validation (e.g. expect(SC_NOT_IMPLEMENTED)) which fails the response handling when the server returns a different status. The message '501 Not Implemented' appears when the expectation check fails and the mismatch is reported.

Source

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

   * When the verticle does not use a {@link #getWorkerPoolName() named worker pool}, this option has no effect.
   *
   * @return the maximum number of worker threads
   */
  public int getWorkerPoolSize() {
    return workerPoolSize;
  }

  /**
   * Set the maximum number of worker threads to be used by the Vert.x instance.
   * <p>
   * When the verticle does not use a {@link #getWorkerPoolName() named worker pool}, this option has no effect.
   *
   * @param workerPoolSize the number of threads
   * @return a reference to this, so the API can be used fluently
   */
  public DeploymentOptions setWorkerPoolSize(int workerPoolSize) {
    if (workerPoolSize < 1) {
      throw new IllegalArgumentException("size must be > 0");
    }
    this.workerPoolSize = workerPoolSize;
    return this;
  }

  /**
   * Get the value of max worker execute time, in {@link DeploymentOptions#setMaxWorkerExecuteTimeUnit maxWorkerExecuteTimeUnit}.
   * <p>
   * Vert.x will automatically log a warning if it detects that worker threads haven't returned within this time.
   * <p>
   * This can be used to detect where the user is blocking a worker thread for too long. Although worker threads
   * can be blocked longer than event loop threads, they shouldn't be blocked for long periods of time.
   * <p>
   * When the verticle does not use a {@link #getWorkerPoolName() named worker pool}, this option has no effect.
   *
   * @return The value of max worker execute time, the default value of {@link DeploymentOptions#setMaxWorkerExecuteTimeUnit} {@code maxWorkerExecuteTimeUnit} is {@link TimeUnit#NANOSECONDS}
   */
  public long getMaxWorkerExecuteTime() {

View on GitHub (pinned to fb308bd8c3)

Solutions

  1. Ensure the request under test is actually expected to produce 501; if any 2xx is acceptable, drop the expectation or use a status-range expectation instead.
  2. Inspect the actual response status returned by the server and align the expectation (e.g. use SC_OK or SC_BAD_REQUEST) or fix the server behavior.
  3. If you need a custom set of statuses, build the expectation with HttpResponseExpectation.status(int) or the oneOf-style combinators rather than a single 501 constant.

Example fix

// before
request.expect(HttpResponseExpectation.SC_NOT_IMPLEMENTED).send().onSuccess(resp -> ...);
// after
request.expect(HttpResponseExpectation.status(200)).send().onSuccess(resp -> ...);
Defensive patterns

Strategy: validation

Validate before calling

int status = 501; // only assert SC_NOT_IMPLEMENTED if the contract guarantees this code
if (expectedStatus != 501) throw new IllegalArgumentException("Use HttpResponseExpectation.status(" + expectedStatus + ") instead");

Prevention

When it happens

Trigger: Calling vertx HTTP client expectation APIs (io.vertx.core.http.HttpResponseExpectation.SC_NOT_IMPLEMENTED, e.g. request.expect(HttpResponseExpectation.SC_NOT_IMPLEMENTED) or Future.expect) against a response whose status code is not exactly 501.

Common situations: Testing that a server rejects unsupported HTTP methods/features; asserting a proxy returns 501 for an unsupported upgrade; writing contract tests where the endpoint should not implement an operation.

Related errors


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