eclipse-vertx/vert.x · error · IllegalArgumentException

Invalid step

Error message

Invalid step

What it means

progressTo(step) moves the CloseSequence to a target step index, which must fall within [0, steps.size()-1]. Passing an index outside that range is rejected with IllegalArgumentException("Invalid step"), as documented by the method's @throws clause.

Source

Thrown at vertx-core/src/main/java/io/vertx/core/internal/CloseSequence.java:65

    this.steps = steps;
    this.current = sequence.length;
    this.idx = sequence.length;
  }

  public synchronized boolean started() {
    return idx < sequence.length;
  }

  /**
   * Advance the sequence to the specified {@code step}.
   *
   * @param step the target step
   * @return the future completed upon step completion
   * @throws IllegalArgumentException when the {@code step} falls out of the actual range
   */
  public Future<Void> progressTo(int step) {
    if (step < 0 || step > steps.size() - 1) {
      throw new IllegalArgumentException("Invalid step");
    }
    boolean checkProgress;
    synchronized (this) {
      if (step < idx) {
        checkProgress = idx == current;
        idx = step;
      } else {
        checkProgress = false;
      }
    }
    if (checkProgress) {
      tryProgress();
    }
    return steps.get(step).future();
  }

  private void tryProgress() {
    int curr;

View on GitHub (pinned to fb308bd8c3)

Solutions

  1. Use an index in the range 0..(number of Closeables - 1)
  2. Compute the last step as sequence.length - 1, not sequence.length
  3. Re-derive indices from the actual Closeable[] passed to the constructor rather than hardcoding

Example fix

// before
seq.progressTo(steps.length); // out of range, throws
// after
seq.progressTo(steps.length - 1);
Defensive patterns

Strategy: validation

Validate before calling

int stepCount = closables.length;
if (step < 0 || step >= stepCount) {
  throw new IllegalArgumentException("step must be in [0, " + (stepCount - 1) + "]");
}
seq.progressTo(step);

Try / catch

try {
  seq.progressTo(step);
} catch (IllegalArgumentException e) {
  log.error("Invalid close step " + step + " for sequence of size " + closables.length);
}

Prevention

When it happens

Trigger: Calling progressTo with a negative step, a step equal to the number of steps, or an index computed against a different/larger sequence than the one constructed.

Common situations: External orchestrators (e.g. Vertx close logic) computing the final step as steps.length instead of steps.length-1; reuse of a hardcoded index after the sequence definition changed.


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