{"record":{"id":"e6d497c6831d69f2","repo":"apache/cassandra","slug":"latency-must-be-specified-in-terms-of-milliseconds","errorCode":null,"errorMessage":"Latency must be specified in terms of milliseconds (with 'ms' suffix)","messagePattern":"Latency must be specified in terms of milliseconds \\(with 'ms' suffix\\)","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"src/java/org/apache/cassandra/net/ArtificialLatency.java","lineNumber":288,"sourceCode":"            }\n        }\n\n        private void drainIn()\n        {\n            for (Delayed delayed = in.poll(); delayed != null ; delayed = in.poll())\n                out.add(delayed);\n        }\n    }\n\n    public static String getArtificialLatencies()\n    {\n        return artificialLatencies;\n    }\n\n    private static long parseNanos(String latency)\n    {\n        if (!latency.endsWith(\"ms\"))\n            throw new IllegalArgumentException(\"Latency must be specified in terms of milliseconds (with 'ms' suffix)\");\n\n        return TimeUnit.MILLISECONDS.toNanos(Long.parseLong(latency.substring(0, latency.length() - 2)));\n    }\n\n    public static void setArtificialLatencies(String latencies)\n    {\n        setArtificialLatencies(latencies, parseNanos(ARTIFICIAL_LATENCY_LIMIT.getString()));\n    }\n\n    public static void unsafeSetArtificialLatencies(String latencies)\n    {\n        setArtificialLatencies(latencies, Long.MAX_VALUE);\n    }\n\n    private static synchronized void setArtificialLatencies(String latencies, long nanoLimit)\n    {\n        if (latencies.indexOf(',') < 0)\n        {","sourceCodeStart":270,"sourceCodeEnd":306,"githubUrl":"https://github.com/apache/cassandra/blob/88fd0f6a0eaed8943f05ac9e8f947882b8ddc8f1/src/java/org/apache/cassandra/net/ArtificialLatency.java#L270-L306","documentation":"ArtificialLatency.parseNanos parses a latency string that must be expressed in milliseconds with an explicit 'ms' suffix (e.g. \"5ms\"). If the string does not end with 'ms', an IllegalArgumentException is thrown before any numeric parsing.","triggerScenarios":"Calling ArtificialLatency.setArtificialLatencies (or the cassandra.yaml/advanced config artificial_latency setting, or nanos()) with a latency value lacking the 'ms' suffix, e.g. \"100\" or \"100us\" or \"1s\".","commonSituations":"Configuring test_latency / artificial latency settings without units; migrating configs from formats that used raw numbers; typos like \"100 MS\" (uppercase or space) which also fail endsWith(\"ms\").","solutions":["Append the 'ms' suffix to the latency value, e.g. \"100ms\"","Use lowercase 'ms' with no whitespace between number and unit","Convert other units to milliseconds before configuring (e.g. \"1000ms\" instead of \"1s\")","Check the cassandra.yaml value for artificial latency settings and ensure every entry ends in 'ms'"],"exampleFix":"// before\nArtificialLatency.setArtificialLatencies(\"100\");\n\n// after\nArtificialLatency.setArtificialLatencies(\"100ms\");\n","handlingStrategy":"validation","validationCode":"function validateLatency(latency) {\n  if (!/^\\d+ms$/.test(latency)) throw new Error(\"Latency must be like '100ms': \" + latency);\n}","typeGuard":"static boolean isValidLatency(String s) { return s != null && s.matches(\"\\\\d+ms\"); }","tryCatchPattern":"try { ArtificialLatency.setArtificialLatencies(value); }\ncatch (IllegalArgumentException e) { logger.error(\"Bad latency format: {}\", value); }","preventionTips":["Always include the lowercase 'ms' suffix on latency values","No whitespace between number and unit","Convert other units to milliseconds before configuring"],"tags":["configuration","format","latency"],"backgroundTag":"invalid-argument-format","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"}