apache/hadoop · error · IllegalArgumentException
sleepTime = ${sleepTime} < 0
Error message
sleepTime = ${sleepTime} < 0 What it means
The second fail-fast check in RetryLimited's constructor: sleepTime, the fixed delay between retries, must be non-negative. A negative sleep cannot be scheduled and always indicates bad configuration or a swapped-argument bug; the message includes the offending value.
Source
Thrown at hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/io/retry/RetryPolicies.java:275
* The actual sleep time of the n-th retry is f(n, sleepTime),
* where f is a function provided by the subclass implementation.
*
* The object of the subclasses should be immutable;
* otherwise, the subclass must override hashCode(), equals(..) and toString().
*/
static abstract class RetryLimited implements RetryPolicy {
final int maxRetries;
final long sleepTime;
final TimeUnit timeUnit;
private String myString;
RetryLimited(int maxRetries, long sleepTime, TimeUnit timeUnit) {
if (maxRetries < 0) {
throw new IllegalArgumentException("maxRetries = " + maxRetries+" < 0");
}
if (sleepTime < 0) {
throw new IllegalArgumentException("sleepTime = " + sleepTime + " < 0");
}
this.maxRetries = maxRetries;
this.sleepTime = sleepTime;
this.timeUnit = timeUnit;
}
@Override
public RetryAction shouldRetry(Exception e, int retries, int failovers,
boolean isIdempotentOrAtMostOnce) throws Exception {
if (retries >= maxRetries) {
return new RetryAction(RetryAction.RetryDecision.FAIL, 0 , getReason());
}
return new RetryAction(RetryAction.RetryDecision.RETRY,
timeUnit.toMillis(calculateSleepTime(retries)), getReason());
}
protected String getReason() {View on GitHub (pinned to 2add963021)
Solutions
- Log the raw config value before policy construction and fix the negative property.
- Guard computed sleeps with Math.max(0, value) at the source.
- Re-check the constructor/factory parameter order if the value in the message looks like another argument.
Example fix
// before
RetryPolicy p = RetryPolicies.retryUpToMaximumCount(3, -500, TimeUnit.MILLISECONDS);
// after
long sleepMs = Math.max(0, conf.getLong("my.retry.sleep.ms", 500));
RetryPolicy p = RetryPolicies.retryUpToMaximumCount(3, sleepMs, TimeUnit.MILLISECONDS); Defensive patterns
Strategy: validation
Validate before calling
long sleepMs = conf.getLong("my.retry.sleep.ms", 500);
if (sleepMs < 0) {
throw new IllegalArgumentException(
"my.retry.sleep.ms must be >= 0, got " + sleepMs);
} Prevention
- Reject negative duration properties at config load with the property name.
- Clamp computed backoff values with Math.max(0, value) at the source.
- Double-check parameter order when constructing policies after refactors.
When it happens
Trigger: Passing a negative sleepTime to any RetryLimited-based factory — negative config values, argument-order mixups (sleepTime and timeUnit/count positions swapped), or computed backoff values that underflow.
Common situations: Hand-edited retry sleep properties set negative; refactors changing parameter order; defaults computed as base - offset going below zero.
Related errors
- maxRetries = ${maxRetries} < 0
- numRetries = ${numRetries} < 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/8343353292c27452.
Report an issue: GitHub.