apache/cassandra · error · IllegalArgumentException
does not match
Error message
{text} does not match {TIME} What it means
Thrown by TimeoutStrategy.parseInMicros when the text does not match the TIME regex, which recognizes duration values with time units (us/ms/s/m/h/d etc.). The message shows the offending text and the expected pattern.
Solutions
- Append a recognized time unit: us, ms, s, m, h, or d (e.g. '100ms').
- Check for and remove stray whitespace or typo'd units.
- Use the pattern in the message to confirm which units the TIME regex accepts.
Example fix
// before
long micros = TimeoutStrategy.parseInMicros("100"); // missing unit
// after
long micros = TimeoutStrategy.parseInMicros("100ms"); Defensive patterns
Strategy: validation
Validate before calling
if (text == null || !text.matches("[0-9]+(?:\\.[0-9]+)?(?:us|ms|s|m|h|d)")) throw new IllegalArgumentException("duration must be <number><unit>, got: " + text); Try / catch
try { long micros = TimeoutStrategy.parseInMicros(text); }
catch (IllegalArgumentException e) { if (e.getMessage().contains("does not match")) { /* append a valid unit */ } throw e; } Prevention
- Always include a time unit ('100ms', not '100')
- Use only supported units (us, ms, s, m, h, d)
- Trim whitespace from config values before parsing
When it happens
Trigger: Calling parseInMicros (directly or via parse/parseWait/modifier) with a string that is not '<number><unit>', e.g. '100' with no unit, 'ms100', or a misspelled unit.
Common situations: Omitting the time unit ('100' instead of '100ms'); unsupported units like 'sec' or 'minutes'; extra whitespace or invisible characters in config values.
Understand the failure class
Background: "invalid duration" / "failed to parse duration": why your timeout, interval, or TTL string is rejected and which formats each library accepts — this error's family across 32 libraries.
Related errors
- does not match
- Invalid latency modifier specification
- Invalid specification
- Unrecognised attempt modifier
- is not a parsable long (base10) for
AI-assisted analysis of apache/cassandra@88fd0f6a0e (2026-09-10).
Data as JSON: /api/errors/08a1cf6581b6df35.
Report an issue: GitHub.
Appendix: source
Thrown at src/java/org/apache/cassandra/service/TimeoutStrategy.java:392
return new Wait.Constant(((Constant) supplier).micros);
if (modifier == null)
modifier = modifiers.identity();
return new Wait.Modifying(supplier, modifier);
}
public static long parseInMicros(String input, long orElse)
{
if (input == null)
return orElse;
return parseInMicros(input);
}
public static long parseInMicros(String text)
{
Matcher m = TIME.matcher(text);
if (!m.matches())
throw new IllegalArgumentException(text + " does not match " + TIME);
if (text.length() == 1)
{
Invariants.require(text.charAt(0) == '0');
return 0;
}
char penultimate = text.charAt(text.length() - 2);
switch (penultimate)
{
default: return parseInt(text.substring(0, text.length() - 1)) * 1000_000L;
case 'm': return parseInt(text.substring(0, text.length() - 2)) * 1000L;
case 'u': return parseInt(text.substring(0, text.length() - 2));
}
}
private static String orElse(Supplier<String> get, String orElse)
{View on GitHub (pinned to 88fd0f6a0e)