apache/hadoop · error · IllegalArgumentException
numRetries = ${numRetries} < 0
Error message
numRetries = ${numRetries} < 0 What it means
MultipleLinearRandomRetry.Pair holds one rung of a piecewise retry schedule — (numRetries, sleepMillis), e.g. '6 retries 10s apart, then 10 retries 60s apart'. The Pair constructor rejects negative numRetries: a schedule with a negative count is meaningless and always points to a parsing or configuration error upstream.
Source
Thrown at hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/io/retry/RetryPolicies.java:395
/**
* Given pairs of number of retries and sleep time (n0, t0), (n1, t1), ...,
* the first n0 retries sleep t0 milliseconds on average,
* 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;
View on GitHub (pinned to 2add963021)
Solutions
- Validate the spec string at config-load time and fail with the offending token and property name.
- Fix the negative number in the policy spec.
- If counts are computed, floor them at 0 before constructing Pair.
Example fix
// before new MultipleLinearRandomRetry.Pair(-3, 5000); // after Preconditions.checkArgument(numRetries >= 0, "bad retry spec token: %s", raw); new MultipleLinearRandomRetry.Pair(numRetries, sleepMillis);
Defensive patterns
Strategy: validation
Validate before calling
Preconditions.checkArgument(numRetries >= 0,
"retry count must be >= 0, got %s (spec token: %s)", numRetries, rawToken); Prevention
- Validate parsed retry specs at load time and echo the offending token.
- Prefer schema-checked config tooling over hand-edited spec strings.
- Round-trip test spec parsing: parse then re-serialize and compare.
When it happens
Trigger: Building Pair from parsed retry-spec strings (dfs.client.retry.policy.spec, format like '10000,6,60000,10') where a negative number was typed, or from arithmetic that underflows before construction.
Common situations: Hand-edited retry policy specs in site XML with a stray minus sign ('-3,5000'); tooling writing negative defaults; token pairs misaligned so a sleep lands in the count slot.
Related errors
- maxRetries = ${maxRetries} < 0
- sleepTime = ${sleepTime} < 0
- sleepMillis = ${sleepMillis} < 0
- pairs must be neither null nor empty.
- min sleep time must be positive number and max sleep time mu
AI-assisted analysis of apache/hadoop@2add963021 (2026-08-22).
Data as JSON: /api/errors/f43bb29782cef220.
Report an issue: GitHub.