apache/hadoop · error · IllegalArgumentException

sleepMillis = ${sleepMillis} < 0

Error message

sleepMillis = ${sleepMillis} < 0

What it means

The second constructor guard on MultipleLinearRandomRetry.Pair: sleepMillis, the delay for that rung of the piecewise retry schedule, must be non-negative. A negative delay cannot be scheduled; like the count guard, it exists to turn a bad parsed spec into an immediate, descriptive failure.

Source

Thrown at hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/io/retry/RetryPolicies.java:398

   * the following n1 retries sleep t1 milliseconds on average, and so on.
   * 
   * For all the sleep, the actual sleep time is randomly uniform distributed
   * in the close interval [0.5t, 1.5t], where t is the sleep time specified.
   *
   * The objects of this class are immutable.
   */
  public static class MultipleLinearRandomRetry implements RetryPolicy {
    /** Pairs of numRetries and sleepSeconds */
    public static class Pair {
      final int numRetries;
      final int sleepMillis;
      
      public Pair(final int numRetries, final int sleepMillis) {
        if (numRetries < 0) {
          throw new IllegalArgumentException("numRetries = " + numRetries+" < 0");
        }
        if (sleepMillis < 0) {
          throw new IllegalArgumentException("sleepMillis = " + sleepMillis + " < 0");
        }

        this.numRetries = numRetries;
        this.sleepMillis = sleepMillis;
      }
      
      @Override
      public String toString() {
        return numRetries + "x" + sleepMillis + "ms";
      }
    }

    private final List<Pair> pairs;
    private String myString;

    public MultipleLinearRandomRetry(List<Pair> pairs) {
      if (pairs == null || pairs.isEmpty()) {
        throw new IllegalArgumentException("pairs must be neither null nor empty.");

View on GitHub (pinned to 2add963021)

Solutions

  1. Re-validate the spec string and print the parsed pairs before construction to spot misalignment.
  2. Fix the negative delay value in the configuration.
  3. Clamp computed sleeps with Math.max(0, value) at the source.

Example fix

// before
new MultipleLinearRandomRetry.Pair(3, -1000);

// after
long sleep = Math.max(0L, parseSleep(token));
new MultipleLinearRandomRetry.Pair(3, sleep);
Defensive patterns

Strategy: validation

Validate before calling

Preconditions.checkArgument(sleepMillis >= 0,
    "retry sleep must be >= 0, got %s (spec token: %s)", sleepMillis, rawToken);

Prevention

When it happens

Trigger: Parsed specs with a negative delay token, or misaligned token pairs where a count lands in the sleep slot; computed backoff offsets underflowing below zero.

Common situations: Retry spec strings edited by hand with negative values; token pairs shifted after inserting/removing a number; sleeps computed as base*factor - offset going negative.

Related errors


AI-assisted analysis of apache/hadoop@2add963021 (2026-08-22). Data as JSON: /api/errors/8b9f2d6e4fd28696. Report an issue: GitHub.