{"record":{"id":"f43bb29782cef220","repo":"apache/hadoop","slug":"numretries-numretries-0","errorCode":null,"errorMessage":"numRetries = ${numRetries} < 0","messagePattern":"numRetries = (.+?) < 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":395,"sourceCode":"  /**\n   * Given pairs of number of retries and sleep time (n0, t0), (n1, t1), ...,\n   * the first n0 retries sleep t0 milliseconds on average,\n   * the following n1 retries sleep t1 milliseconds on average, and so on.\n   * \n   * For all the sleep, the actual sleep time is randomly uniform distributed\n   * in the close interval [0.5t, 1.5t], where t is the sleep time specified.\n   *\n   * The objects of this class are immutable.\n   */\n  public static class MultipleLinearRandomRetry implements RetryPolicy {\n    /** Pairs of numRetries and sleepSeconds */\n    public static class Pair {\n      final int numRetries;\n      final int sleepMillis;\n      \n      public Pair(final int numRetries, final int sleepMillis) {\n        if (numRetries < 0) {\n          throw new IllegalArgumentException(\"numRetries = \" + numRetries+\" < 0\");\n        }\n        if (sleepMillis < 0) {\n          throw new IllegalArgumentException(\"sleepMillis = \" + sleepMillis + \" < 0\");\n        }\n\n        this.numRetries = numRetries;\n        this.sleepMillis = sleepMillis;\n      }\n      \n      @Override\n      public String toString() {\n        return numRetries + \"x\" + sleepMillis + \"ms\";\n      }\n    }\n\n    private final List<Pair> pairs;\n    private String myString;\n","sourceCodeStart":377,"sourceCodeEnd":413,"githubUrl":"https://github.com/apache/hadoop/blob/2add9630210752f88ceb1bb74eb65e37bf41da8e/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/io/retry/RetryPolicies.java#L377-L413","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","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."],"exampleFix":"// before\nnew MultipleLinearRandomRetry.Pair(-3, 5000);\n\n// after\nPreconditions.checkArgument(numRetries >= 0, \"bad retry spec token: %s\", raw);\nnew MultipleLinearRandomRetry.Pair(numRetries, sleepMillis);","handlingStrategy":"validation","validationCode":"Preconditions.checkArgument(numRetries >= 0,\n    \"retry count must be >= 0, got %s (spec token: %s)\", numRetries, rawToken);","typeGuard":null,"tryCatchPattern":null,"preventionTips":["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."],"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"}