{"record":{"id":"33b442b700e8fe4f","repo":"apache/cassandra","slug":"set-twice","errorCode":null,"errorMessage":" set twice","messagePattern":" set twice","errorType":"exception","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"tools/stress/src/org/apache/cassandra/stress/settings/OptionAnyProbabilities.java","lineNumber":50,"sourceCode":"{\n    public OptionAnyProbabilities(String name, String description)\n    {\n        super(name, description, false);\n    }\n\n    final CollectRatios ratios = new CollectRatios();\n\n    private static final class CollectRatios extends Option\n    {\n        Map<String, Double> options = new LinkedHashMap<>();\n\n        boolean accept(String param)\n        {\n            String[] args = param.split(\"=\");\n            if (args.length == 2 && args[1].length() > 0 && args[0].length() > 0)\n            {\n                if (options.put(args[0], Double.valueOf(args[1])) != null)\n                    throw new IllegalArgumentException(args[0] + \" set twice\");\n                return true;\n            }\n            return false;\n        }\n\n        boolean happy()\n        {\n            return !options.isEmpty();\n        }\n\n        String shortDisplay()\n        {\n            return null;\n        }\n        public String getOptionAsString()\n        {\n            StringBuilder sb = new StringBuilder();\n            for (Map.Entry<String, Double> entry : options.entrySet())","sourceCodeStart":32,"sourceCodeEnd":68,"githubUrl":"https://github.com/apache/cassandra/blob/88fd0f6a0eaed8943f05ac9e8f947882b8ddc8f1/tools/stress/src/org/apache/cassandra/stress/settings/OptionAnyProbabilities.java#L32-L68","documentation":"OptionAnyProbabilities parses weight=probability pairs like read=0.5,write=0.5. If the same option key appears twice, the second put would silently overwrite the first, so the parser detects an existing entry and throws '<key> set twice' IllegalArgumentException instead.","triggerScenarios":"Specifying the same probability key twice in a stress command, e.g. stress read read=0.3,read=0.7 or duplicate keys in an options list like -rate threads=10 ... threads=20 handled by this option.","commonSituations":"Building the stress command programmatically and appending duplicate option strings; concatenating command lines from scripts; typo'd key variants that normalize to the same name.","solutions":["Remove the duplicate key, keeping one entry per operation type","De-duplicate programmatically built argument lists before invoking stress","Use distinct keys for distinct operations (read=, write=, counterwrite=, etc.)"],"exampleFix":"// before\nstress mixed read=0.3,read=0.7,write=0.4\n// after\nstress mixed read=0.6,write=0.4","handlingStrategy":"validation","validationCode":"Map<String,Double> seen = new HashMap<>();\nfor (String p : probabilityArgs) {\n    String[] kv = p.split(\"=\");\n    if (seen.putIfAbsent(kv[0], Double.valueOf(kv[1])) != null)\n        throw new IllegalArgumentException(kv[0] + \" set twice\");\n}","typeGuard":null,"tryCatchPattern":"try { parseOption(param); } catch (IllegalArgumentException e) { log.error(\"Duplicate option: {}\", e.getMessage()); }","preventionTips":["De-duplicate programmatically generated stress arguments","Keep one entry per operation key in probability lists","Review concatenated command lines for repeated keys"],"tags":["cli","argument-parsing","duplicate"],"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"}