{"record":{"id":"8343353292c27452","repo":"apache/hadoop","slug":"sleeptime-sleeptime-0","errorCode":null,"errorMessage":"sleepTime = ${sleepTime} < 0","messagePattern":"sleepTime = (.+?) < 0","errorType":"exception","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/io/retry/RetryPolicies.java","lineNumber":275,"sourceCode":"   * The actual sleep time of the n-th retry is f(n, sleepTime),\n   * where f is a function provided by the subclass implementation.\n   *\n   * The object of the subclasses should be immutable;\n   * otherwise, the subclass must override hashCode(), equals(..) and toString().\n   */\n  static abstract class RetryLimited implements RetryPolicy {\n    final int maxRetries;\n    final long sleepTime;\n    final TimeUnit timeUnit;\n    \n    private String myString;\n\n    RetryLimited(int maxRetries, long sleepTime, TimeUnit timeUnit) {\n      if (maxRetries < 0) {\n        throw new IllegalArgumentException(\"maxRetries = \" + maxRetries+\" < 0\");\n      }\n      if (sleepTime < 0) {\n        throw new IllegalArgumentException(\"sleepTime = \" + sleepTime + \" < 0\");\n      }\n\n      this.maxRetries = maxRetries;\n      this.sleepTime = sleepTime;\n      this.timeUnit = timeUnit;\n    }\n\n    @Override\n    public RetryAction shouldRetry(Exception e, int retries, int failovers,\n        boolean isIdempotentOrAtMostOnce) throws Exception {\n      if (retries >= maxRetries) {\n        return new RetryAction(RetryAction.RetryDecision.FAIL, 0 , getReason());\n      }\n      return new RetryAction(RetryAction.RetryDecision.RETRY,\n          timeUnit.toMillis(calculateSleepTime(retries)), getReason());\n    }\n\n    protected String getReason() {","sourceCodeStart":257,"sourceCodeEnd":293,"githubUrl":"https://github.com/apache/hadoop/blob/2add9630210752f88ceb1bb74eb65e37bf41da8e/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/io/retry/RetryPolicies.java#L257-L293","documentation":"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.","triggerScenarios":"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.","commonSituations":"Hand-edited retry sleep properties set negative; refactors changing parameter order; defaults computed as base - offset going below zero.","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."],"exampleFix":"// before\nRetryPolicy p = RetryPolicies.retryUpToMaximumCount(3, -500, TimeUnit.MILLISECONDS);\n\n// after\nlong sleepMs = Math.max(0, conf.getLong(\"my.retry.sleep.ms\", 500));\nRetryPolicy p = RetryPolicies.retryUpToMaximumCount(3, sleepMs, TimeUnit.MILLISECONDS);","handlingStrategy":"validation","validationCode":"long sleepMs = conf.getLong(\"my.retry.sleep.ms\", 500);\nif (sleepMs < 0) {\n  throw new IllegalArgumentException(\n      \"my.retry.sleep.ms must be >= 0, got \" + sleepMs);\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["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."],"tags":["retry-policy","configuration","illegal-argument","hadoop-common"],"backgroundTag":"invalid-config-value","analyzedSha":"2add9630210752f88ceb1bb74eb65e37bf41da8e","analyzedAt":"2026-08-22T19:55:07.957Z","schemaVersion":2},"datasetVersion":"2026-08-22T20:17:22.307Z"}