{"record":{"id":"2f6ced8870517bd9","repo":"apache/cassandra","slug":"randomizer-already-specified-cannot-re-specify","errorCode":null,"errorMessage":"Randomizer already specified, cannot re-specify: ${value}","messagePattern":"Randomizer already specified, cannot re-specify: (.+?)","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"src/java/org/apache/cassandra/service/RetryStrategy.java","lineNumber":293,"sourceCode":"                    throw new IllegalArgumentException(\"Invalid modifier specification: '\" + spec.substring(next, end) + \"'; expecting '=' for value assignment\");\n                String key = spec.substring(next + 1, mid).trim();\n                String value = spec.substring(mid + 1, end).trim();\n                switch (key)\n                {\n                    default: throw new IllegalArgumentException(\"Invalid modifier specification: unrecognised property '\" + key + '\\'');\n                    case \"retries\":\n                        retries = Integer.parseInt(value);\n                        if (retries < 0)\n                            throw new IllegalArgumentException(\"retries must be non-negative (retries=\" + value + \" supplied)\");\n                        break;\n                    case \"attempts\":\n                        retries = Integer.parseInt(value);\n                        if (retries < 0)\n                            throw new IllegalArgumentException(\"Must permit at least one attempt (attempts=\" + value + \" supplied)\");\n                        break;\n                    case \"rnd\":\n                        if (randomizer != null)\n                            throw new IllegalArgumentException(\"Randomizer already specified, cannot re-specify: \" + value);\n                        randomizer = parseWaitRandomizer(value);\n                        break;\n                }\n                end = next;\n            }\n            if (end != spec.length())\n                spec = spec.substring(0, end);\n        }\n\n        Matcher m = PARSE.matcher(spec);\n        if (!m.matches())\n            throw new IllegalArgumentException(\"Invalid specification: '\" + spec + \"'; does not match \" + PARSE);\n\n        long minMin = parseInMicros(m.group(\"minmin\"), 0);\n        long maxMax = parseInMicros(m.group(\"maxmax\"), Long.MAX_VALUE);\n        Wait max = TimeoutStrategy.parseWait(m.group(\"max\"), latencies);\n        String minSpec = m.group(\"min\");\n        Wait min = minSpec == null ? null : TimeoutStrategy.parseWait(minSpec, latencies);","sourceCodeStart":275,"sourceCodeEnd":311,"githubUrl":"https://github.com/apache/cassandra/blob/88fd0f6a0eaed8943f05ac9e8f947882b8ddc8f1/src/java/org/apache/cassandra/service/RetryStrategy.java#L275-L311","documentation":"The 'rnd=<randomizer>' modifier sets the wait randomizer, but it can only be specified once. If a randomizer was already supplied (via the parse overload's randomizer parameter or an earlier rnd modifier), RetryStrategy.parse() throws rather than silently overriding it.","triggerScenarios":"RetryStrategy.parse(spec, latencies, existingRandomizer) where spec also contains ',rnd=...' — or a spec containing two rnd modifiers, e.g. \"100ms..1s,rnd=exp(2),rnd=uniform\".","commonSituations":"Merging config fragments that each carry an rnd modifier; programmatically passing a WaitRandomizer while also keeping an rnd clause from a serialized spec string.","solutions":["Remove one of the two rnd specifications so only one remains","If you must supply the randomizer programmatically, strip the ',rnd=...' clause from the spec string","If two rnd clauses exist in the spec, delete the redundant one"],"exampleFix":"// before\nRetryStrategy.parse(\"100ms..1s,rnd=exp(2),rnd=uniform\", latencies, randomizer);\n// after\nRetryStrategy.parse(\"100ms..1s,rnd=exp(2)\", latencies); // single source of randomizer","handlingStrategy":"validation","validationCode":"static String stripRndModifier(String spec) {\n    return spec.replaceAll(\",rnd=[^,]+\", \"\");\n}\n// pass randomizer programmatically OR via spec, never both\nRetryStrategy.parse(stripRndModifier(spec), latencies, suppliedRandomizer);","typeGuard":null,"tryCatchPattern":"try {\n    RetryStrategy strategy = RetryStrategy.parse(spec, latencies, randomizer);\n} catch (IllegalArgumentException e) {\n    if (e.getMessage().startsWith(\"Randomizer already specified\")) {\n        return RetryStrategy.parse(spec.replaceAll(\",rnd=[^,]+$\", \"\"), latencies, randomizer);\n    }\n    throw e;\n}","preventionTips":["Choose one source of truth for the randomizer: spec string or parameter","When merging config fragments, deduplicate rnd clauses","Centralize spec construction so rnd cannot be appended twice"],"tags":["configuration","parsing","conflicting-options"],"backgroundTag":"conflicting-config-options","analyzedSha":"88fd0f6a0eaed8943f05ac9e8f947882b8ddc8f1","analyzedAt":"2026-09-10T07:29:22.284Z","contentChangedAt":"2026-09-10T07:29:22.284Z","schemaVersion":2},"datasetVersion":"2026-09-17T15:17:12.973Z"}